diff --git a/amxmodx/file.cpp b/amxmodx/file.cpp index 5ada0d6f..1cecdeda 100755 --- a/amxmodx/file.cpp +++ b/amxmodx/file.cpp @@ -774,6 +774,21 @@ static cell AMX_NATIVE_CALL amx_ungetc(AMX *amx, cell *params) return ungetc(static_cast(params[2]), fp); } +#if defined __linux__ +#define _rmdir rmdir +#endif + +static cell AMX_NATIVE_CALL amx_rmdir(AMX *amx, cell *params) +{ + int len; + char* sFile = build_pathname("%s", get_amxstring(amx, params[1], 0, len)); + + if (_rmdir(sFile) != 0) + return 0; + + return 1; +} + AMX_NATIVE_INFO file_Natives[] = { {"delete_file", delete_file}, @@ -806,5 +821,6 @@ AMX_NATIVE_INFO file_Natives[] = {"fgetc", amx_fgetc}, {"fputc", amx_fputc}, {"fungetc", amx_ungetc}, + {"rmdir", amx_rmdir}, {NULL, NULL} }; diff --git a/plugins/include/file.inc b/plugins/include/file.inc index 61dda8b9..1bc1fd12 100755 --- a/plugins/include/file.inc +++ b/plugins/include/file.inc @@ -89,6 +89,11 @@ native fungetc(file, data); //Return the size of a file native filesize(const filename[],{Float,Sql,Result,_}:...); +//Attempts to remove a directory. +//Note that you cannot remove a directory that has files on most +// operating systems. +native rmdir(const path[]); + //Delete a file (delete_file macro) native unlink(const filename[],{Float,Sql,Result,_}:...);