public OnConfigsExecuted()
{
for(new a = 0; a < sizeof(SearchFolders); a++)
{
ReadDirectories(a);
}
}
ReadDirectories(index)
{
// Store path history
new Handle:folder_history = CreateArray(ByteCountToCells(PLATFORM_MAX_PATH));
new String:file[PLATFORM_MAX_PATH]; // Buffer file name
new String:location[PLATFORM_MAX_PATH]; // Buffer current location path
new String:next_location[PLATFORM_MAX_PATH]; // Buffer next location path
// Loop as long as we are back root folder (ex. materials)
while(dir != INVALID_HANDLE)
{
// Loop to read files from current directory
while(ReadDirEntry(dir, file, sizeof(file), type))
{
if(type == FileType_Directory) // folders only
{
if( !StrEqual(file, ".", false) && !StrEqual(file, "..", false) ) // skip "levels"
{
// Next location
Format(next_location, sizeof(next_location), "%s/%s", location, file);
// We already visit there... skip
if( FindStringInArray(folder_history, next_location) != -1 )
{
continue;
}
else // NEW directory!
{
// Save path location in history
PushArrayString(folder_history, next_location);
strcopy(location, sizeof(location), next_location);
//PrintToServer("location %s", location);
// Let's read files from here new directory
CloseHandle(dir);
dir = OpenDirectory(location);
CloseHandle(dir);
dir = OpenDirectory(location);
}
}
}
}
CloseHandle(dir);
// Go directories/like/this <- backwards
charact = FindCharInString(location, '/', true);
if(charact != -1)
{
// remove last folder name from string.
location[charact] = '\0';
dir = OpenDirectory(location);
}
else // we have visit on all sub folders
{
dir = INVALID_HANDLE;
}
}
CloseHandle(folder_history);
}
friagram
07-24-2014 18:01
Re: Find loosed files from specific folders with specific file extensions in each fol
There are more model files than the ones listed there like the dx8/9 components.