Author Topic: Information from utListDir command  (Read 6908 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Information from utListDir command
« on: March 09, 2015, 03:24:30 PM »
Hi Mark,
  I was thinking about using the ulListDir command to go through the whole sd card (trailing into directories and collecting files), is there a way to detect after the call if the entry is directory or a file? If so are there any variables that can get the file, or directory  name ?

Thanks
Neil


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Information from utListDir command
« Reply #1 on: March 09, 2015, 03:52:45 PM »
Neil

To check the entry type you can use:

if (fileList.ucFileAttributes & DIR_ATTR_ARCHIVE) { // if a file
}


The list entry also contains some string details about the entry in the list buffer, where the name of file/directory string is present. From these details a pointer can be set to the start of the name (last entry in the string) as follows:

CHAR *ptrFileName = &cBuffer[fileList.usStringLength - fileList.ucNameLength]; // set pointer to null terminated file name
where cBuffer[] is the buffer that you configured for the listing to be placed into.

As reference see the SD card serial loader (in Kinetis project) which performs an optional wildcard file search using the methods above.

Regards

Mark


Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Information from utListDir command
« Reply #2 on: March 26, 2015, 10:14:14 AM »
Hi Mark,
  I dont have the Kinetis project, can you please email me the function that performs an optional wildcard file search?

Bets Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Information from utListDir command
« Reply #3 on: March 26, 2015, 05:38:24 PM »
Hi Neil

I have attached the file involved - search for WILDCARD_FILES

Regards

Mark


Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Information from utListDir command
« Reply #4 on: March 26, 2015, 06:20:14 PM »
Thanks Mark


Regards
Neil