Raised This Month: $32 Target: $400
 8% 

How to delete a directory?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 03-02-2014 , 08:52   How to delete a directory?
Reply With Quote #1

??
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-02-2014 , 09:32   Re: How to delete a directory?
Reply With Quote #2

rmdir()

Next time, search yourself among the AMXX includes files, here file.inc.
__________________
Arkshine is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 03-02-2014 , 10:03   Re: How to delete a directory?
Reply With Quote #3

I searched in the documentation but nothing showed up for rmdir. Never mind.

It only seems to delete empty directories. How can I delete a non-empty directory without deleting the files one by one?
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 03-02-2014 , 10:25   Re: How to delete a directory?
Reply With Quote #4

Quote:
Originally Posted by Desikac View Post
I searched in the documentation but nothing showed up for rmdir. Never mind.

It only seems to delete empty directories. How can I delete a non-empty directory without deleting the files one by one?
Cann't, since most OS just won't allow it.
__________________
simanovich is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-02-2014 , 11:45   Re: How to delete a directory?
Reply With Quote #5

Code:
stock rmdir2(dir[]) {         new hDir, len = strlen(dir);     static tempfile[1024];     copy(tempfile, charsmax(tempfile), dir);         if ( ! ( tempfile[len - 1] == '/' || tempfile[len - 1] == '\' ) ) { //'         tempfile[len++] = '\'; //'         tempfile[len] = 0;     }         if ( ! ( hDir = open_dir(dir, tempfile[len], charsmax(tempfile) - len) ) )         return 0;         do {         if ( equal(tempfile[len], ".") || equal(tempfile[len], "..") )             continue;                 if ( dir_exists(tempfile) ) {             if ( ! rmdir2(tempfile) )                 return 0;         }         else {             if ( ! delete_file(tempfile) )                 return 0;         }     }     while ( next_file(hDir, tempfile[len], charsmax(tempfile) - len ) )         close_dir(hDir);     dir[len] = 0;     rmdir(dir);         return 1; }

Pre:


Post:
Nothing. Directory, including all files and subfolders, is gone.
Attached Thumbnails
Click image for larger version

Name:	test.png
Views:	354
Size:	18.2 KB
ID:	131069  
__________________

Last edited by Black Rose; 03-02-2014 at 12:09.
Black Rose is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 03-02-2014 , 19:48   Re: How to delete a directory?
Reply With Quote #6

Works perfectly! Thanks, exactly what I needed.
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
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 09:01.


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