Added CreateDirectory() native and a few permissions macros (bug 3253, r=ds).
This commit is contained in:
parent
09ea2e13aa
commit
556c03babf
@ -487,6 +487,21 @@ static cell_t sm_FileSize(IPluginContext *pContext, const cell_t *params)
|
||||
#endif
|
||||
}
|
||||
|
||||
static cell_t sm_CreateDirectory(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *name;
|
||||
char realpath[PLATFORM_MAX_PATH];
|
||||
|
||||
pContext->LocalToString(params[1], &name);
|
||||
g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", name);
|
||||
|
||||
#if defined PLATFORM_WINDOWS
|
||||
return mkdir(realpath) == 0;
|
||||
#else
|
||||
return mkdir(realpath, params[2]) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static cell_t sm_RemoveDir(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *name;
|
||||
@ -959,5 +974,6 @@ REGISTER_NATIVES(filesystem)
|
||||
{"WriteFileString", sm_WriteFileString},
|
||||
{"AddGameLogHook", sm_AddGameLogHook},
|
||||
{"RemoveGameLogHook", sm_RemoveGameLogHook},
|
||||
{"CreateDirectory", sm_CreateDirectory},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
@ -353,6 +353,25 @@ native FlushFile(Handle:file);
|
||||
*/
|
||||
native bool:RemoveDir(const String:path[]);
|
||||
|
||||
#define FPERM_U_READ 0x0100 /* User can read. */
|
||||
#define FPERM_U_WRITE 0x0080 /* User can write. */
|
||||
#define FPERM_U_EXEC 0x0040 /* User can exec. */
|
||||
#define FPERM_G_READ 0x0020 /* Group can read. */
|
||||
#define FPERM_G_WRITE 0x0010 /* Group can write. */
|
||||
#define FPERM_G_EXEC 0x0008 /* Group can exec. */
|
||||
#define FPERM_O_READ 0x0004 /* Anyone can read. */
|
||||
#define FPERM_O_WRITE 0x0002 /* Anyone can write. */
|
||||
#define FPERM_O_EXEC 0x0001 /* Anyone can exec. */
|
||||
|
||||
/**
|
||||
* Creates a directory.
|
||||
*
|
||||
* @param path Path to create.
|
||||
* @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have
|
||||
* the execute bit set on Linux. On Windows, the mode is ignored.
|
||||
*/
|
||||
native bool:CreateDirectory(const String:path[], mode);
|
||||
|
||||
/**
|
||||
* Returns a file timestamp as a unix timestamp.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user