Correct UnixSetFileAccess to allow chmoding a directory

This commit is contained in:
JustArchi 2020-05-24 00:17:36 +02:00
parent ee3a9cf6fd
commit 7930a652dd

View file

@ -138,7 +138,7 @@ namespace ArchiSteamFarm {
}
internal static void UnixSetFileAccess(string path, EUnixPermission permission) {
if (string.IsNullOrEmpty(path) || !File.Exists(path)) {
if (string.IsNullOrEmpty(path)) {
ASF.ArchiLogger.LogNullError(nameof(path));
return;
@ -148,6 +148,12 @@ namespace ArchiSteamFarm {
return;
}
if (!File.Exists(path) && !Directory.Exists(path)) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningFailedWithError, "!" + nameof(path)));
return;
}
// Chmod() returns 0 on success, -1 on failure
if (NativeMethods.Chmod(path, (int) permission) != 0) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningFailedWithError, Marshal.GetLastWin32Error()));