From deccf7816ce300f0fc41a499d0fcb51d269868ac Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 30 Mar 2006 00:48:58 +0000 Subject: [PATCH] added rmdir() --- amxmodx/file.cpp | 16 ++++++++++++++++ plugins/include/file.inc | 5 +++++ 2 files changed, 21 insertions(+) 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,_}:...);