View Single Post
Author Message
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 01-13-2014 , 12:00   [STOCK] SearchCustomDir
Reply With Quote #1

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(hCustomDirszBuffersizeof(szBuffer), iFileType)) {
            if (
iFileType == FileType_Directory) {
                
Format(szBuffersizeof(szBuffer), "custom/%s/%s"szBufferszInput);

                if (
FileExists(szBuffertrue)) {
                    
strcopy(szOutputiMaxLenszBuffer);
                    return 
true;
                }
            }
        }
    }

    return 
false;

bl4nk is offline