Takes a given path input, and if it finds the file in the "custom" dir, it outputs the correct path. Useful for using OpenFile or other file-related functions that don't have the ability to search the Valve filesystem (such as FileExists).
PHP Code:
stock bool:SearchCustomDir(const String:szInput[], String:szOutput[], iMaxLen) {
new Handle:hCustomDir = OpenDirectory("custom");
if (hCustomDir != INVALID_HANDLE) {
decl String:szBuffer[PLATFORM_MAX_PATH], FileType:iFileType;
while (ReadDirEntry(hCustomDir, szBuffer, sizeof(szBuffer), iFileType)) {
if (iFileType == FileType_Directory) {
Format(szBuffer, sizeof(szBuffer), "custom/%s/%s", szBuffer, szInput);
if (FileExists(szBuffer, true)) {
strcopy(szOutput, iMaxLen, szBuffer);
return true;
}
}
}
}
return false;
}