Hello!
I'm trying to set a files permission but I'm unable to, here is a list what I've debugged.
> I've made sure that the path is correct and that the file exist using
FileExists()
> I have also made sure that the folder that the files are in have the permission 777
> I've have made sure that I have the correct plugin file on my server, by setting the plugin version and then checking the version in the console with the
sm plugins command
But yet I have not succeeded to set the files permission.
Here is my code:
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma tabsize 0
char g_sFileName[128];
public Plugin myinfo =
{
name = "",
author = "",
description = "",
version = "1.4",
url = ""
};
public void OnPluginStart()
{
HookEvent("round_start", Event_RoundStart);
HookEvent("round_end", Event_RoundEnd);
}
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
if(GameRules_GetProp("m_bWarmupPeriod"))
return Plugin_Handled;
SetFileName(); // Set the file name
ServerCommand("tv_record \"%s\"", g_sFileName);
char file[255];
Format(file, sizeof(file), "/home/ogp_agent/OGP_User_Files/dev/csgo/%s.dem", g_sFileName);
PrintToConsoleAll("[DEBUG] Started recording: %s", file);
return Plugin_Handled;
}
public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
if(GameRules_GetProp("m_bWarmupPeriod"))
return Plugin_Handled;
ServerCommand("tv_stoprecord");
char oldPath[255];
Format(oldPath, sizeof(oldPath), "/home/ogp_agent/OGP_User_Files/dev/csgo/%s.dem", g_sFileName);
PrintToConsoleAll("[DEBUG] Stopped recording: %s", oldPath);
if(FileExists(oldPath, true, NULL_STRING))
{
if(SetFilePermissions(oldPath, FPERM_U_READ|FPERM_U_WRITE|FPERM_U_EXEC|FPERM_G_READ|FPERM_G_WRITE|FPERM_G_EXEC|FPERM_O_READ|FPERM_O_WRITE|FPERM_O_EXEC))
PrintToConsoleAll("[DEBUG] File permission changed on %s", oldPath);
else
PrintToConsoleAll("[DEBUG] File permission was not set");
}
return Plugin_Handled;
}
public void SetFileName()
{
char time[32];
char map[32];
FormatTime(time, sizeof(time), "%Y%m%d_%H-%M-%S", GetTime());
GetCurrentMap(map, sizeof(map));
Format(g_sFileName, sizeof(g_sFileName), "demos/turf_%s_%s", map, time);
}
I keep getting the "
[DEBUG] File permission was not set" message sent in console. Why isn't the file's permission being set?