Raised This Month: $12 Target: $400
 3% 

[STOCK] SearchCustomDir


Post New Thread Reply   
 
Thread Tools Display Modes
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
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:10.


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