/// <summary> /// Attempts to change the mode of the specified file or dir to that given in mode. /// </summary> /// <param name="path">The specified file or dir.</param> /// <param name="mode">The mode for the unix.</param> public static void Chmod(string path, int mode) { // Only valid under unix. if (Platform.IsWindows || !FileSystem.Exists(path)) { return; } PermissionUnix.Chmod(path, mode); }
/// <summary> /// Transfer the permissions of the source file(or dir) to the target file(or dir). /// </summary> /// <remarks>It is not allowed to pass permissions between folders and files, this will return false.</remarks> /// <returns>True if transfer successful. false if the <paramref name="destination"/> not exists.</returns> public static bool TransferPerms(string source, string destination) { if (!FileSystem.Exists(source) || !FileSystem.Exists(destination)) { return(false); } var sourceIsDir = FileSystemLocal.IsDirectory(source); var destinationIsDir = FileSystemLocal.IsDirectory(destination); // Ensure source is same type for the destination. if (sourceIsDir != destinationIsDir) { return(false); } if (Platform.IsWindows) { return(PermissionWindows.TransferPerms(source, destination, sourceIsDir)); } return(PermissionUnix.TransferPerms(source, destination)); }