Retrieve a list of files and/or folders contained in a folder.
int FolderGet( char *path, char *filters, short options, FOLDER *pFolder );
Routine | Required Header |
FolderGet | "folder.h" |
Libraries
OKLIB.A | Oankali GP32 run-time library |
Return Value
FolderGet can return one of the following values defined in FOLDER.H:
fldOk
Execution completed correctly.
fldBadFolder
Folder not found or the the folder couldn't be read.
fldMemory
Not enough memory.
fldAttributes
File/folder attributes couldn't be retrieved.
Parameters
path
String containing the path of the folder to be browsed.
filters
String containing a list of filters to be applied on the files/folders to return. Filters in the list have to be separated by semi-colons (;).
options
Type of operations allowed.
pFolder
Pointer to a FOLDER structure.
Remarks
GpFatInit must have been called before to call FolderGet.
The FolderGet function reads all the files in the folder path, filters them according to the filters list and the options flags. The list of files/folders is returned through the pFolder->pEntries chained list. The list is sorted alphabetically. Folders comes first, then files.
If an error occurs, only files and/or folders processed until the error raised are returned in the chained list. In this case you should always test pFolder->pEntries before trying to get list entries.
You can filter files/folders returned by the function using the filters string. Filters works DOS/UNIX style: multiple * and ? wildcards are allowed.
options is an integer expression formed from one or more of the following constants or constant combinations defined in FOLDER.H:
FLD_FILES
Add files that meet pFilters criteria to the returned list.
FLD_FOLDERS
Add folders that meet pFilters criteria to the returned list.
FLD_EXPLORE
Add folder ".." as the first folder in the list to allow the exploration of the parent folder.
FLD_ALL
All constants combined together.
The options argument determines the type of list that will be returned. When two or more constants are used to form the options argument, the constants are combined with the bitwise-OR operator ( | ).
To release resources allocated by FolderGet, FolderDrop should always be called after finalizing the processing of the pFolder->pEntries list, and that even if FolderGet returned an error.
Example
|
See Also
Folder Routines, Folder Constants, FolderDrop, FOLDER, FOLDERENTRY