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

Stock DeleteDirectory


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 05-30-2017 , 05:36   Stock DeleteDirectory
Reply With Quote #1

Maybe someone is searching for this

As of this writing I noticed that RemoveDir native does not support valve file system

PHP Code:
/**
 * Deletes a directory/folder recursively.
 *
 * @param path            Path to directory/folder.
 * @param use_valve_fs  If true, the Valve file system will be used instead.
 *                      This can be used to find files existing in any of
 *                      the Valve search paths, rather than solely files
 *                      existing directly in the gamedir.
 * @param valve_path_id    If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
 * @return                True on success and false otherwise.
 * @error                Directory is not exists or unaccessable. 
 */
stock bool:DeleteDirectory(const String:path[], bool:use_valve_fs=false, const String:valve_path_id[]="GAME")
{
    
decl String:dirEntry[PLATFORM_MAX_PATH];
    
    new 
Handle:__dir OpenDirectory(pathuse_valve_fsvalve_path_id);
    if (
__dir != INVALID_HANDLE)
    {
        new 
FileType:file_type FileType_Unknown;
        while (
ReadDirEntry(__dirdirEntrysizeof(dirEntry), file_type))
        {
            if (
StrEqual(dirEntry".") || StrEqual(dirEntry".."))
            {
                continue;
            }
            
            switch (
file_type)
            {
                case 
FileType_File :
                {
                    
Format(dirEntrysizeof(dirEntry), "%s/%s"pathdirEntry);
                    
DeleteFile(dirEntryuse_valve_fsvalve_path_id);
                }
                case 
FileType_Directory :
                {
                    
Format(dirEntrysizeof(dirEntry), "%s/%s"pathdirEntry);
                    
DeleteDirectory(dirEntryuse_valve_fsvalve_path_id);
                }
            }
        }
        
CloseHandle(__dir);
        
        return 
RemoveDir(path);
    }
    
    
LogError("Directory %s does not exist or is inaccessible!"path);
    
    return 
false;


Last edited by Despirator; 06-02-2017 at 14:40.
Despirator is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-30-2017 , 07:38   Re: Stock DeleteDirectory
Reply With Quote #2

Quote:
Originally Posted by Despirator View Post
As of this writing I noticed that RemoveDir native does not support valve file system
The Valve filesystem interface does not have a call for that.
psychonic is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 06-02-2017 , 00:25   Re: Stock DeleteDirectory
Reply With Quote #3

Quote:
Directory %s is not exists or is unaccessable
Directory %s does not exist, or is inaccessible.

Last edited by 404UserNotFound; 06-02-2017 at 00:26.
404UserNotFound is offline
Reply



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 14:44.


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