예제 #1
0
        /// <summary>
        /// Calculate the CHMOD integer value given a set of permissions.
        /// </summary>
        public static int CalcChmod(FtpPermission owner, FtpPermission group, FtpPermission other)
        {
            var chmod = 0;

            if (HasPermission(owner, FtpPermission.Read))
            {
                chmod += 400;
            }

            if (HasPermission(owner, FtpPermission.Write))
            {
                chmod += 200;
            }

            if (HasPermission(owner, FtpPermission.Execute))
            {
                chmod += 100;
            }

            if (HasPermission(group, FtpPermission.Read))
            {
                chmod += 40;
            }

            if (HasPermission(group, FtpPermission.Write))
            {
                chmod += 20;
            }

            if (HasPermission(group, FtpPermission.Execute))
            {
                chmod += 10;
            }

            if (HasPermission(other, FtpPermission.Read))
            {
                chmod += 4;
            }

            if (HasPermission(other, FtpPermission.Write))
            {
                chmod += 2;
            }

            if (HasPermission(other, FtpPermission.Execute))
            {
                chmod += 1;
            }

            return(chmod);
        }
예제 #2
0
 /// <summary>
 /// Checks if the permission value has the given flag
 /// </summary>
 public static bool HasPermission(FtpPermission owner, FtpPermission flag)
 {
     return((owner & flag) == flag);
 }
예제 #3
0
 /// <summary>
 /// Modify the permissions of the given file/folder.
 /// Only works on *NIX systems, and not on Windows/IIS servers.
 /// Only works if the FTP server supports the SITE CHMOD command
 /// (requires the CHMOD extension to be installed and enabled).
 /// Throws FtpCommandException if there is an issue.
 /// </summary>
 /// <param name="path">The full or relative path to the item</param>
 /// <param name="owner">The owner permissions</param>
 /// <param name="group">The group permissions</param>
 /// <param name="other">The other permissions</param>
 /// <param name="token">The token that can be used to cancel the entire process</param>
 public Task ChmodAsync(string path, FtpPermission owner, FtpPermission group, FtpPermission other, CancellationToken token = default(CancellationToken))
 {
     return(SetFilePermissionsAsync(path, owner, group, other, token));
 }
예제 #4
0
 /// <summary>
 /// Modify the permissions of the given file/folder.
 /// Only works on *NIX systems, and not on Windows/IIS servers.
 /// Only works if the FTP server supports the SITE CHMOD command
 /// (requires the CHMOD extension to be installed and enabled).
 /// Throws FtpCommandException if there is an issue.
 /// </summary>
 /// <param name="path">The full or relative path to the item</param>
 /// <param name="owner">The owner permissions</param>
 /// <param name="group">The group permissions</param>
 /// <param name="other">The other permissions</param>
 public void Chmod(string path, FtpPermission owner, FtpPermission group, FtpPermission other)
 {
     SetFilePermissions(path, owner, group, other);
 }
예제 #5
0
 /// <summary>
 /// Modify the permissions of the given file/folder.
 /// Only works on *NIX systems, and not on Windows/IIS servers.
 /// Only works if the FTP server supports the SITE CHMOD command
 /// (requires the CHMOD extension to be installed and enabled).
 /// Throws FtpCommandException if there is an issue.
 /// </summary>
 /// <param name="path">The full or relative path to the item</param>
 /// <param name="owner">The owner permissions</param>
 /// <param name="group">The group permissions</param>
 /// <param name="other">The other permissions</param>
 public void SetFilePermissions(string path, FtpPermission owner, FtpPermission group, FtpPermission other)
 {
     SetFilePermissions(path, FtpExtensions.CalcChmod(owner, group, other));
 }
예제 #6
0
 /// <summary>
 /// Set permissions on the specified object using the chmod command. Some server may not
 /// support chmod so be prepared to handle the subsequent FtpCommandException that may 
 /// be thrown.
 /// </summary>
 /// <param name="path">Path of the object to change the permissions on</param>
 /// <param name="user">Permissions for the user that owns the object</param>
 /// <param name="group">Permissions for the group the object belongs to</param>
 /// <param name="others">Permissions for other users on the system</param>
 public void SetPermissions(string path, FtpPermission user, FtpPermission group, FtpPermission others) {
     this.SetPermissions(path, (uint)user, (uint)group, (uint)others);
 }
예제 #7
0
 public static FtpPermissions ToFtpPermissions(this FtpPermission ftpPermission)
 {
     return((FtpPermissions)ftpPermission);
 }
 public Task <ServiceResult> SetFilePermissionsAsync(string path, FtpPermission owner, FtpPermission group, FtpPermission other, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }