Defined in:Enumerates the files in a given directory.
static void BuildFileMap(const char *directory, Map<FileReference> *map, FileMapFilter *filter = &DefaultFilter, const void *cookie = nullptr);
||A pointer to the name of the directory for which files should be enumerated. If a path name is specified, it is interpreted relative to the application. Multiple directory names should be separated by single forward slash characters (/), but the last directory name in the path should not be followed by a slash.|
||A pointer to an existing map object which is to contain the |
||A pointer to a filter function. This can be omitted, but it cannot be |
||The value that is passed to the |
BuildFileMapfunction enumerates the files in the directory given by the
directoryparameter and instantiates a
FileReferenceobject for each file in the directory. These objects are placed into the list given by the
One typically calls
BuildFileMapto obtain a list of files in a particular directory and then iterates through the list to examine each file individually. When the list of
FileReferenceobjects is no longer needed, the memory for each of the objects should be released. This can be done by calling the
List::PurgeListfunction or by destroying the
If a filter function is specified by the
filterparameter, then it is called for each file as the list is being built to determine whether the file should be included in the list. The
FileMapFiltertype is defined as follows.
typedef bool FileMapFilter(const char *name, uint32 flags, const void *cookie);
nameparameter of the filter function recieves a pointer to the file name, the
flagsparameter receives the flags associated with the file, and the
cookieparameter receives the value passed to the
cookieparameter of the
BuildFileMapfunction. The flags associated with a file can be a combination (through logical OR) of the following constants.
||The file reference represents a directory.|
||The file is invisible.|
trueto indicate that the file should be included in the file list, and it should return
falseto indicate that the file should be skipped.
If no filter function is specified, then the default filter function
FileMgr::DefaultFilteris used. The default filter function returns
kFileInvisibleflag is set or if the file name begins with a period, and returns
trueotherwise. The File Manager also defines two additional filter functions named
FileMgr::DirectoryFilter. Like the default filter function, both of these functions return
kFileInvisibleflag is set or if the file/directory name begins with a period. The
kFileDirectoryflag is set, and the
kFileDirectoryflag is not set.