Ejemplo n.º 1
0
char* HGE_CALL HGE_Impl::Resource_EnumFolders(const char* wildcard) {
    if (wildcard) {
        if (h_search_) {
            FindClose(h_search_);
            h_search_ = nullptr;
        }
        h_search_ = FindFirstFile(Resource_MakePath(wildcard), &search_data_);
        if (h_search_ == INVALID_HANDLE_VALUE) {
            h_search_ = nullptr;
            return nullptr;
        }

        if ((search_data_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
            strcmp(search_data_.cFileName, ".") && strcmp(search_data_.cFileName, "..")) {
            return search_data_.cFileName;
        }
        return Resource_EnumFolders();
    }
    if (!h_search_) {
        return nullptr;
    }
    for (;;) {
        if (!FindNextFile(h_search_, &search_data_)) {
            FindClose(h_search_);
            h_search_ = nullptr;
            return nullptr;
        }
        if ((search_data_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
            strcmp(search_data_.cFileName, ".") && strcmp(search_data_.cFileName, "..")) {
            return search_data_.cFileName;
        }
    }
}
Ejemplo n.º 2
0
char* CALL HGE_Impl::Resource_EnumFolders(const char *wildcard)
{
	if(wildcard)
	{
		if(hSearch) { FindClose(hSearch); hSearch=0; }
		hSearch=FindFirstFile(Resource_MakePath(wildcard), &SearchData);
		if(hSearch==INVALID_HANDLE_VALUE) { hSearch=0; return 0; }

		if((SearchData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
		   strcmp(SearchData.cFileName,".") && strcmp(SearchData.cFileName,".."))
				return SearchData.cFileName;
		else return Resource_EnumFolders();
	}
	else
	{
		if(!hSearch) return 0;
		for(;;)
		{
			if(!FindNextFile(hSearch, &SearchData))	{ FindClose(hSearch); hSearch=0; return 0; }
			if((SearchData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
			   strcmp(SearchData.cFileName,".") && strcmp(SearchData.cFileName,".."))
					return SearchData.cFileName;
		}
	}
}