Beispiel #1
0
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;
}
bool wxDirData::Read(wxString *filename)
{
    PM_findData data;
    bool matches = false;

    data.dwSize = sizeof(data);

    wxString path = m_dirname;
    path += wxFILE_SEP_PATH;
    path.reserve(path.length() + 255); // speed up string concatenation

    while ( !matches )
    {
        if ( m_dir )
        {
            if ( !PM_findNextFile(m_dir, &data) )
                return false;
        }
        else
        {
            m_dir = PM_findFirstFile(path + m_filespec , &data);
            if ( m_dir == PM_FILE_INVALID )
            {
                m_dir = NULL;
                return false;
            }
        }

        // don't return "." and ".." unless asked for
        if ( data.name[0] == '.' &&
             ((data.name[1] == '.' && data.name[2] == '\0') ||
              (data.name[1] == '\0')) )
        {
            if ( !(m_flags & wxDIR_DOTDOT) )
                continue;

            // we found a valid match
            break;
        }

        // check the type now
        if ( !(m_flags & wxDIR_FILES) && !(data.attrib & PM_FILE_DIRECTORY) )
        {
            // it's a file, but we don't want them
            continue;
        }
        else if ( !(m_flags & wxDIR_DIRS) && (data.attrib & PM_FILE_DIRECTORY) )
        {
            // it's a dir, and we don't want it
            continue;
        }

        matches = m_flags & wxDIR_HIDDEN ? true : !(data.attrib & PM_FILE_HIDDEN);
    }

    *filename = data.name;

    return true;
}
Beispiel #3
0
/****************************************************************************
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);
}
Beispiel #4
0
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);
		}
}