Fast and flexible list-of-lists directory trees.
#include <uLib/FileDir.h>
Although DirEntry and FileEntry started off as a fairly simple
directory hierarchy, they have now evolved into a very flexible, fast,
and easy to use hierarchial list-of-lists directory structure
that supports per-thread current directory for concurrent scans.
The primary API is the static DirEntry::ScanDir().
◆ SCF_FILES
Scan flag.. Add files.
Definition at line 253 of file FileDir.h.
◆ SCF_DIRS
Scan flag.. Add directories.
Definition at line 254 of file FileDir.h.
◆ MAX_DIRECTORY_DEPTH
#define MAX_DIRECTORY_DEPTH 256 |
No sane directory hierarchy should get this deep.
Definition at line 259 of file FileDir.h.
◆ PFileEntry
Pointer to a file entry.
Definition at line 42 of file FileDir.h.
◆ PDirEntry
Pointer to a directory entry.
Definition at line 45 of file FileDir.h.
◆ PScanDirCtx
Pointer to a ScanDir context.
Definition at line 46 of file FileDir.h.
◆ PFnDirAddAction
PFnDirAddAction and PFnFileAddAction are callbacks optionally invoked
by DirEntry::Scan() after entry addition. F.ex, you might need to determine the
link count on a file (which takes time and therefore is not included in the base
implementation).
- Parameters
-
pItem | Pointer to the newly allocated entry (PDirEntry or PFileEntry). |
pFD | Pointer to the WIN32_FIND_DATA for the entry. |
Definition at line 55 of file FileDir.h.
◆ PFnFileAddAction
See PFnDirAddAction
Definition at line 56 of file FileDir.h.
◆ PFnDirAction
◆ PFnFileAction
◆ PFnAbortScan
Optional callback to abort a scan in progress.
Return false to continue.
Definition at line 70 of file FileDir.h.
◆ LongestCommonPath()
(Oops... Forgot about PathCommonPrefix()).
LongestCommonPath() returns the longest common part of two path names.
An internal static MAX_PATH buffer is used to return the result.
On error a blank string is returned, and GetLastError() returns a reason.
If the paths have nothing in common, the error is ERROR_NOT_FOUND, and
if the resulting path exceeds MAX_PATH, the error is ERROR_BUFFER_OVERFLOW.
Definition at line 756 of file FileDir.cpp.
◆ NewFileEntry()
NewFileEntry and NewDirEntry are pointers to functions that
DirEntry::Scan() calls to allocate new FileEntry and DirEntry instances.
This enables a degree of polymorphism to be used, e.g. extended entry types.
If needed, write decendants of FileEntry/DirEntry, and then write functions
that return pointers to new instances of your descendants.
Note: For simple entry extension, you may use the pData member
and AddAction/DelAction functions instead of descendant classes.
NewFileEntry and NewDirEntry can also be used as entry filters, by
writing custom functions which return NULL for entries that should not
be added to the directory tree. This causes Scan() to reject them.
- Parameters
-
pfd | Pointer to the WIN32_FIND_DATA for the item. |
pDir | Pointer to the DirEntry currently being scanned. |
- Returns
- Return a pointer to a FileEntry/DirEntry (or descendant), or NULL.
- Warning
- These function pointers must never be NULL, or your scanner will crash.
Pointer to FileEntry instanciator.
◆ NewDirEntry()
◆ __new_FileEntry()
◆ __new_DirEntry()
◆ _defScanCtx
Default scanning context if none provided.
Definition at line 17 of file FileDir.cpp.