Raised This Month: $ Target: $400
 0% 

Delete ? How To ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 12-07-2015 , 10:50   Delete ? How To ?
Reply With Quote #1

How to delete a folder inside amxmodx/configs folder
eg : i want to delete folder named abc inside configs folder by a command how to do it ?

Please give an example plugin
Awesome_man is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-07-2015 , 11:05   Re: Delete ? How To ?
Reply With Quote #2

Code:
//Attempts to remove a directory.
//Note that you cannot remove a directory that has files on most
// operating systems.
native rmdir(const path[]);
Example usage:
Code:
rmdir("addons/amxmodx/configs/myfolder");

Last edited by klippy; 12-07-2015 at 11:06.
klippy is offline
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 12-07-2015 , 11:18   Re: Delete ? How To ?
Reply With Quote #3

Quote:
Originally Posted by KliPPy View Post
Code:
//Attempts to remove a directory.
//Note that you cannot remove a directory that has files on most
// operating systems.
native rmdir(const path[]);
Example usage:
Code:
rmdir("addons/amxmodx/configs/myfolder");
I think rmdir deletes a directory, which must be empty but in my case there are some files which are unused by server and dey can be deleted but how ?
Awesome_man is offline
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 12-07-2015 , 15:11   Re: Delete ? How To ?
Reply With Quote #4

This should work.

PHP Code:
stock boolRemoveDirectoryszDir[ ] ) {
    
    new 
iDiriLen strlenszDir );
    new 
szTemporaryFile1024] ;
    
    
copyszTemporaryFilecharsmaxszTemporaryFile ), szDir );
    
    if( !( 
szTemporaryFileiLen ] == '/' || szTemporaryFileiLen ] == '\' ) ) { //'
        
szTemporaryFileiLen++ ] = '\'; //'
        
szTemporaryFileiLen ] = 0;
    }
    
    if( !( 
iDir open_dirszDirszTemporaryFileiLen ], ( charsmaxszTemporaryFile ) - iLen ) ) ) )
        return 
false;
    
    do {
        if( 
equalszTemporaryFileiLen ], "." ) || equalszTemporaryFileiLen ], ".." ) )
            continue;
        
        if ( 
dir_existsszTemporaryFile ) ) {
            if ( !
RemoveDirectoryszTemporaryFile ) )
                return 
false;
        } else {
            if ( !
delete_fileszTemporaryFile ) )
                return 
false;
        }
    } while ( 
next_fileiDirszTemporaryFileiLen ], ( charsmaxszTemporaryFile ) - iLen ) ) );
    
    
close_diriDir );
    
szDiriLen ] = 0;
    
rmdirszDir );
    return 
true;


Last edited by milutinke; 12-07-2015 at 15:12.
milutinke is offline
Send a message via Skype™ to milutinke
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 18:15.


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