implemented request at28875
This commit is contained in:
parent
38cb60c60b
commit
8da4987895
|
@ -554,6 +554,18 @@ static cell AMX_NATIVE_CALL amx_fread_blocks(AMX *amx, cell *params)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL amx_fputs(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
FILE *fp = (FILE *)params[1];
|
||||||
|
|
||||||
|
if (!fp)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int len;
|
||||||
|
char *str = get_amxstring(amx, params[2], 0, len);
|
||||||
|
return fputs(str, fp);
|
||||||
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
FILE *fp = (FILE *)params[1];
|
FILE *fp = (FILE *)params[1];
|
||||||
|
@ -787,6 +799,19 @@ static cell AMX_NATIVE_CALL amx_rmdir(AMX *amx, cell *params)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL amx_rename(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *fold = get_amxstring(amx, params[1], 0, len);
|
||||||
|
char *fnew = get_amxstring(amx, params[2], 1, len);
|
||||||
|
|
||||||
|
#if defined __linux__
|
||||||
|
return (rename(fold, fnew) == 0);
|
||||||
|
#elif defined WIN32
|
||||||
|
return MoveFileA(fold, fnew);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO file_Natives[] =
|
AMX_NATIVE_INFO file_Natives[] =
|
||||||
{
|
{
|
||||||
{"delete_file", delete_file},
|
{"delete_file", delete_file},
|
||||||
|
@ -820,5 +845,7 @@ AMX_NATIVE_INFO file_Natives[] =
|
||||||
{"fputc", amx_fputc},
|
{"fputc", amx_fputc},
|
||||||
{"fungetc", amx_ungetc},
|
{"fungetc", amx_ungetc},
|
||||||
{"rmdir", amx_rmdir},
|
{"rmdir", amx_rmdir},
|
||||||
|
{"fputs", amx_fputs},
|
||||||
|
{"rename_file", amx_rename},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,6 +28,10 @@ native delete_file(const file[]);
|
||||||
/* Checks for file. If file exists function returns 1, in other case 0. */
|
/* Checks for file. If file exists function returns 1, in other case 0. */
|
||||||
native file_exists(const file[]);
|
native file_exists(const file[]);
|
||||||
|
|
||||||
|
/* renames a file. returns 0 on failure, 1 on success.
|
||||||
|
*/
|
||||||
|
native rename_file(const oldname[], const newname[]);
|
||||||
|
|
||||||
/* Checks if a directory exists */
|
/* Checks if a directory exists */
|
||||||
native dir_exists(const dir[]);
|
native dir_exists(const dir[]);
|
||||||
|
|
||||||
|
@ -72,6 +76,9 @@ native feof(file);
|
||||||
//Reads a line from a text file -- includes newline!
|
//Reads a line from a text file -- includes newline!
|
||||||
native fgets(file, buffer[], maxlength);
|
native fgets(file, buffer[], maxlength);
|
||||||
|
|
||||||
|
//Writes a line to a text file. Returns # of characters written.
|
||||||
|
native fputs(file, const text[]);
|
||||||
|
|
||||||
//Writes a line to the file
|
//Writes a line to the file
|
||||||
native fprintf(file, const fmt[], {Float,Sql,Result,_}:...);
|
native fprintf(file, const fmt[], {Float,Sql,Result,_}:...);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user