I put this together, but it doesn't work >_<. I'll fool around with it later, but I want you guys to look at it and tell me what's wrong.
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Recursive Delete Directory"
#define VERSION "1.0"
#define AUTHOR "stupok69"
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR )
register_concmd( "deldir", "cmd_delete" )
}
public cmd_delete()
{
new arg[64]
read_argv( 1, arg, 63 )
while( dir_exists( arg ) )
{
delete_dir_recursive( arg )
}
}
stock delete_dir_recursive( szFullPath[64] )
{
if( !dir_exists( szFullPath ) )
return 0
if( rmdir( szFullPath ) )
return 1
static dirh, szNextFile[sizeof szFullPath]
dirh = open_dir( szFullPath, szNextFile, sizeof szNextFile - 1 )
// szNextFile = " ."
next_file( dirh, szNextFile, sizeof szNextFile - 1 )
// szNextFile = ".."
while( next_file( dirh, szNextFile, sizeof szNextFile - 1 ) )
{
if( file_exists( szNextFile ) )
{
delete_file( szNextFile )
}
else if( dir_exists( szNextFile ) )
{
if( !rmdir( szNextFile ) )
{
close_dir( dirh )
delete_dir_recursive( szNextFile )
}
}
}
close_dir( dirh )
return 1
}