static ibool issubdirectory(const char *dir) /**************************************************************************** * * Function: issubdirectory * Parameters: dir - Name of the file to check * Returns: True if a subdirectory, false if a normal file * * Description: Checks if the specified file is a subdirectory or a normal * file. * ****************************************************************************/ { PM_findData findData; void *hfile; ibool isdir = false; char path[PM_MAX_PATH]; strcpy(path,dir); if (path[strlen(path)-1] == '\\') path[strlen(path)-1] = 0; if ((hfile = PM_findFirstFile(path,&findData)) != NULL) { if (findData.attrib & PM_FILE_DIRECTORY) isdir = true; } if (hfile) PM_findClose(hfile); if (isrootdirectory(dir)) return true; return isdir; }
static ibool loaddirectories(const char *filename,FileList& fileList) /**************************************************************************** * * Function: loaddirectories * Parameters: filename - Name of directories to look for * fileList - Place to store the filenames * Returns: True on success, false on memory error * * Description: Loads a list of all the directories from the current * directory into the specified name list. * ****************************************************************************/ { PM_findData findData; void *hfile; ibool valid; valid = (hfile = PM_findFirstFile(filename,&findData)) != NULL; while (valid) { if ((findData.attrib & PM_FILE_DIRECTORY) && findData.name[0] != '.') { fileList.add(new TCDynStr(findData.name)); if (MV_lowMemory()) return false; } valid = PM_findNextFile(hfile,&findData); } if (hfile) PM_findClose(hfile); return true; }
void wxDirData::Rewind() { if ( m_dir ) { PM_findClose(m_dir); m_dir = NULL; } }
static ibool validfilename(const char *path) /**************************************************************************** * * Function: validfilename * Parameters: path - Name of the file to check * Returns: True if a valid file, false if non existant or a directory * * Description: Checks if the specified file is a valid filename. * ****************************************************************************/ { PM_findData findData; void *hfile; ibool valid = false; if ((hfile = PM_findFirstFile(path,&findData)) != NULL) { if (!(findData.attrib & PM_FILE_DIRECTORY)) valid = true; } if (hfile) PM_findClose(hfile); return valid; }
/**************************************************************************** PARAMETERS: path - directory to scan for fonts wildcard - wildcard to match. cache - local cache for one directory REMARKS: Enumerates fonts in path matching wildard and puts information about them into directory cache cache. {secret} ****************************************************************************/ static void enumFontsByWildcard( const char *path, const char *wildcard, dirCache *cache) { char fullwild[PM_MAX_PATH]; PM_findData findData; void *handle; strcpy(fullwild, path); PM_backslash(fullwild); strcat(fullwild, wildcard); findData.dwSize = sizeof(findData); handle = PM_findFirstFile(fullwild, &findData); if (handle == PM_FILE_INVALID) return; do { enumFontFile(path, findData.name, cache); } while (PM_findNextFile(handle, &findData)); PM_findClose(handle); }
void recurseCollectFiles( FILE *log, const char *path, const char *fileMask, ibool logCVS) { PM_findData findData; void *hfile; int done; char files[PM_MAX_PATH]; char name[PM_MAX_PATH]; // First dump all matching files findData.dwSize = sizeof(findData); strcpy(files,path); if (strlen(path) > 0) PM_backslash(files); #ifndef __UNIX__ if (strcmp(fileMask,"*") == 0) strcat(files,"*.*"); else #endif strcat(files,fileMask); done = (hfile = PM_findFirstFile(files,&findData)) == PM_FILE_INVALID; while (!done) { strcpy(name,path); if (strlen(path) > 0) PM_backslash(name); strcat(name,findData.name); if (!(findData.attrib & PM_FILE_DIRECTORY)) fprintf(log,"%s\n", name); done = !PM_findNextFile(hfile,&findData); } if (hfile != PM_FILE_INVALID) PM_findClose(hfile); // Now recurse all subdirectories strcpy(files,path); if (strlen(path) > 0) PM_backslash(files); #ifdef __UNIX__ strcat(files,"*"); #else strcat(files,"*.*"); #endif done = (hfile = PM_findFirstFile(files,&findData)) == PM_FILE_INVALID; while (!done) { if ((strcmp(findData.name,".") != 0) && (strcmp(findData.name,"..") != 0)) { if (findData.attrib & PM_FILE_DIRECTORY) { strcpy(name,path); if (strlen(path) > 0) PM_backslash(name); strcat(name,findData.name); if (logCVS && (strcmp(findData.name,"CVS") == 0 || strcmp(findData.name,"CVSROOT") == 0)) { recurseCollectFiles(log,name,"*",false); } else recurseCollectFiles(log,name,fileMask,logCVS); } } done = !PM_findNextFile(hfile,&findData); } }
wxDirData::~wxDirData() { if ( m_dir ) PM_findClose(m_dir); }