From 7930a652dd948a1503c2a3b468fff5df7a9737f6 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sun, 24 May 2020 00:17:36 +0200 Subject: [PATCH] Correct UnixSetFileAccess to allow chmoding a directory --- ArchiSteamFarm/OS.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ArchiSteamFarm/OS.cs b/ArchiSteamFarm/OS.cs index 802167b6e..d318e1334 100644 --- a/ArchiSteamFarm/OS.cs +++ b/ArchiSteamFarm/OS.cs @@ -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()));