コード例 #1
0
ファイル: OS.cs プロジェクト: petchnoi/ArchiSteamFarm
        internal static void UnixSetFileAccess(string path, EUnixPermission permission)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                return;
            }

            if (!File.Exists(path) && !Directory.Exists(path))
            {
                ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, 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(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, Marshal.GetLastWin32Error()));
            }
        }
コード例 #2
0
        internal static void UnixSetFileAccess(string path, EUnixPermission permission)
        {
            if (string.IsNullOrEmpty(path))
            {
                ASF.ArchiLogger.LogNullError(nameof(path));

                return;
            }

            if (!IsUnix)
            {
                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()));
            }
        }