#include <fileutil.h>
Public Member Functions | |
FindFiles () | |
BOOL | StartFindingFiles (String_256 *FileSpecifier) |
Scans a given directory for files matching a particular name. Same as FileUtil::StartFindingFiles but being a class is re-entrant and returns directories so that you can do recursive searches. | |
BOOL | FindNextFile (String_256 *FoundFile, BOOL *IsDirectory) |
Finds the next file, if any. See StartFindingFiles for example search code Notes: ** Note that this will not return system/hidden files **. | |
BOOL | StopFindingFiles () |
Stops a directory scan To find files, do something like the following See StartFindingFiles for example search code DO NOT CALL THIS FUNCTION if StartFindingFiles failed. Call this function exactly once for each call to StartFindingFiles. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (FindFiles) | |
Private Attributes | |
String_256 | m_SearchPath |
Definition at line 179 of file fileutil.h.
|
Definition at line 184 of file fileutil.h.
|
|
|
|
Finds the next file, if any. See StartFindingFiles for example search code Notes: ** Note that this will not return system/hidden files **.
Definition at line 771 of file fileutil.cpp. 00772 { 00773 ERROR3IF(FoundFile == NULL || IsDirectory == NULL, "Illegal NULL param"); 00774 00775 BOOL result = TRUE; 00776 00777 while (result) 00778 { 00779 if (m_SearchHandle == INVALID_HANDLE_VALUE) 00780 { 00781 // find first 00782 m_SearchHandle = ::FindFirstFile((TCHAR *)m_SearchPath, &m_SearchData); 00783 result = (m_SearchHandle != INVALID_HANDLE_VALUE); 00784 } 00785 else 00786 { 00787 // find next 00788 result = ::FindNextFile(m_SearchHandle, &m_SearchData); 00789 } 00790 00791 if (result) 00792 { 00793 // Only return "files" which are not system or hidden 00794 const DWORD AttrMask = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM; 00795 const DWORD AttrDirMask = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM; 00796 TCHAR * ThisDir = "."; 00797 TCHAR * ParentDir = ".."; 00798 INT32 len = camStrclen(m_SearchData.cFileName); 00799 if ((m_SearchData.dwFileAttributes & AttrMask) == 0) 00800 { 00801 // OK, it's a safe file to return, so return it 00802 *FoundFile = m_SearchData.cFileName; 00803 *IsDirectory = FALSE; 00804 return TRUE; 00805 } 00806 else if (((m_SearchData.dwFileAttributes & AttrDirMask) == 0) && 00807 // (cc_lstrncmp(m_SearchData.cFileName, ThisDir, len) != 0) && 00808 // (cc_lstrncmp(m_SearchData.cFileName, ParentDir, len) != 0)) 00809 (camStrncmp(m_SearchData.cFileName, ThisDir, len) != 0) && 00810 (camStrncmp(m_SearchData.cFileName, ParentDir, len) != 0)) 00811 { 00812 // OK, it's a safe directory to return, so return it 00813 *FoundFile = m_SearchData.cFileName; 00814 *IsDirectory = TRUE; 00815 return TRUE; 00816 } 00817 } 00818 } 00819 00820 *FoundFile = TEXT(""); 00821 *IsDirectory = FALSE; 00822 return FALSE; 00823 }
|
|
Scans a given directory for files matching a particular name. Same as FileUtil::StartFindingFiles but being a class is re-entrant and returns directories so that you can do recursive searches.
Definition at line 738 of file fileutil.cpp. 00739 { 00740 ERROR3IF(FileSpecifier == NULL, "Duff FileSpecifier param"); 00741 00742 m_SearchHandle = INVALID_HANDLE_VALUE; 00743 m_SearchPath = *FileSpecifier; 00744 00745 return(TRUE); 00746 }
|
|
Stops a directory scan To find files, do something like the following See StartFindingFiles for example search code DO NOT CALL THIS FUNCTION if StartFindingFiles failed. Call this function exactly once for each call to StartFindingFiles.
Definition at line 843 of file fileutil.cpp. 00844 { 00845 if (m_SearchHandle != NULL) 00846 ::FindClose(m_SearchHandle); 00847 00848 m_SearchHandle = INVALID_HANDLE_VALUE; 00849 00850 return TRUE; 00851 }
|
|
Definition at line 192 of file fileutil.h. |