AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [STOCK] SearchCustomDir (https://forums.alliedmods.net/showthread.php?t=233354)

bl4nk 01-13-2014 12:00

[STOCK] SearchCustomDir
 
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;




All times are GMT -4. The time now is 07:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.