mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-01-12 14:58:06 +03:00
Fixed bug am46630: rename_file did not have a relative location version
This commit is contained in:
parent
b33e76d9c4
commit
8b8cc3dd6b
@ -799,13 +799,25 @@ static cell AMX_NATIVE_CALL amx_rmdir(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_rename(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_rename(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
char f_old_r[260];
|
||||||
|
char f_new_r[260];
|
||||||
|
|
||||||
char *fold = get_amxstring(amx, params[1], 0, len);
|
char *fold = get_amxstring(amx, params[1], 0, len);
|
||||||
char *fnew = get_amxstring(amx, params[2], 1, len);
|
char *fnew = get_amxstring(amx, params[2], 1, len);
|
||||||
|
|
||||||
|
if (params[0] / sizeof(cell) == 3 && params[3])
|
||||||
|
{
|
||||||
|
build_pathname_r(f_old_r, sizeof(f_old_r)-1, "%s", fold);
|
||||||
|
build_pathname_r(f_new_r, sizeof(f_new_r)-1, "%s", fnew);
|
||||||
|
} else {
|
||||||
|
snprintf(f_old_r, sizeof(f_old_r)-1, "%s", fold);
|
||||||
|
snprintf(f_new_r, sizeof(f_new_r)-1, "%s", fnew);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined __linux__
|
#if defined __linux__
|
||||||
return (rename(fold, fnew) == 0);
|
return (rename(f_old_r, f_new_r) == 0);
|
||||||
#elif defined WIN32
|
#elif defined WIN32
|
||||||
return MoveFileA(fold, fnew);
|
return MoveFileA(f_old_r, f_new_r);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,11 @@ native delete_file(const file[]);
|
|||||||
native file_exists(const file[]);
|
native file_exists(const file[]);
|
||||||
|
|
||||||
/* renames a file. returns 0 on failure, 1 on success.
|
/* renames a file. returns 0 on failure, 1 on success.
|
||||||
|
* if relative true, rename_file will act like other natives which
|
||||||
|
* use the moddir as a base directory. otherwise, the current directory is
|
||||||
|
* undefined (but assumed to be hlds).
|
||||||
*/
|
*/
|
||||||
native rename_file(const oldname[], const newname[]);
|
native rename_file(const oldname[], const newname[], relative=0);
|
||||||
|
|
||||||
/* Checks if a directory exists */
|
/* Checks if a directory exists */
|
||||||
native dir_exists(const dir[]);
|
native dir_exists(const dir[]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user