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())); } }
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())); } }