Rename the file permission statics in std::io to be uppercase

For example, this renames `GroupRWX` to `GROUP_RWX`, and deprecates the old
name. Code using these statics should be updated accordingly.
This commit is contained in:
P1start
2014-10-06 16:08:46 +13:00
parent 5660db2508
commit e3ca987f74
11 changed files with 135 additions and 77 deletions

View File

@@ -1803,35 +1803,93 @@ bitflags! {
#[doc = "A set of permissions for a file or directory is represented"]
#[doc = "by a set of flags which are or'd together."]
flags FilePermission: u32 {
static UserRead = 0o400,
static UserWrite = 0o200,
static UserExecute = 0o100,
static GroupRead = 0o040,
static GroupWrite = 0o020,
static GroupExecute = 0o010,
static OtherRead = 0o004,
static OtherWrite = 0o002,
static OtherExecute = 0o001,
static USER_READ = 0o400,
static USER_WRITE = 0o200,
static USER_EXECUTE = 0o100,
static GROUP_READ = 0o040,
static GROUP_WRITE = 0o020,
static GROUP_EXECUTE = 0o010,
static OTHER_READ = 0o004,
static OTHER_WRITE = 0o002,
static OTHER_EXECUTE = 0o001,
static UserRWX = UserRead.bits | UserWrite.bits | UserExecute.bits,
static GroupRWX = GroupRead.bits | GroupWrite.bits | GroupExecute.bits,
static OtherRWX = OtherRead.bits | OtherWrite.bits | OtherExecute.bits,
static USER_RWX = USER_READ.bits | USER_WRITE.bits | USER_EXECUTE.bits,
static GROUP_RWX = GROUP_READ.bits | GROUP_WRITE.bits | GROUP_EXECUTE.bits,
static OTHER_RWX = OTHER_READ.bits | OTHER_WRITE.bits | OTHER_EXECUTE.bits,
#[doc = "Permissions for user owned files, equivalent to 0644 on"]
#[doc = "unix-like systems."]
static UserFile = UserRead.bits | UserWrite.bits | GroupRead.bits | OtherRead.bits,
static USER_FILE = USER_READ.bits | USER_WRITE.bits | GROUP_READ.bits | OTHER_READ.bits,
#[doc = "Permissions for user owned directories, equivalent to 0755 on"]
#[doc = "unix-like systems."]
static UserDir = UserRWX.bits | GroupRead.bits | GroupExecute.bits |
OtherRead.bits | OtherExecute.bits,
static USER_DIR = USER_RWX.bits | GROUP_READ.bits | GROUP_EXECUTE.bits |
OTHER_READ.bits | OTHER_EXECUTE.bits,
#[doc = "Permissions for user owned executables, equivalent to 0755"]
#[doc = "on unix-like systems."]
static UserExec = UserDir.bits,
static USER_EXEC = USER_DIR.bits,
#[doc = "All possible permissions enabled."]
static AllPermissions = UserRWX.bits | GroupRWX.bits | OtherRWX.bits,
static ALL_PERMISSIONS = USER_RWX.bits | GROUP_RWX.bits | OTHER_RWX.bits,
// Deprecated names
#[allow(non_uppercase_statics)]
#[deprecated = "use USER_READ instead"]
static UserRead = USER_READ.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use USER_WRITE instead"]
static UserWrite = USER_WRITE.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use USER_EXECUTE instead"]
static UserExecute = USER_EXECUTE.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use GROUP_READ instead"]
static GroupRead = GROUP_READ.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use GROUP_WRITE instead"]
static GroupWrite = GROUP_WRITE.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use GROUP_EXECUTE instead"]
static GroupExecute = GROUP_EXECUTE.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use OTHER_READ instead"]
static OtherRead = OTHER_READ.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use OTHER_WRITE instead"]
static OtherWrite = OTHER_WRITE.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use OTHER_EXECUTE instead"]
static OtherExecute = OTHER_EXECUTE.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use USER_RWX instead"]
static UserRWX = USER_RWX.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use GROUP_RWX instead"]
static GroupRWX = GROUP_RWX.bits,
#[allow(non_uppercase_statics)]
#[deprecated = "use OTHER_RWX instead"]
static OtherRWX = OTHER_RWX.bits,
#[doc = "Deprecated: use `USER_FILE` instead."]
#[allow(non_uppercase_statics)]
#[deprecated = "use USER_FILE instead"]
static UserFile = USER_FILE.bits,
#[doc = "Deprecated: use `USER_DIR` instead."]
#[allow(non_uppercase_statics)]
#[deprecated = "use USER_DIR instead"]
static UserDir = USER_DIR.bits,
#[doc = "Deprecated: use `USER_EXEC` instead."]
#[allow(non_uppercase_statics)]
#[deprecated = "use USER_EXEC instead"]
static UserExec = USER_EXEC.bits,
#[doc = "Deprecated: use `ALL_PERMISSIONS` instead"]
#[allow(non_uppercase_statics)]
#[deprecated = "use ALL_PERMISSIONS instead"]
static AllPermissions = ALL_PERMISSIONS.bits,
}
}
@@ -1954,13 +2012,13 @@ mod tests {
fn test_show() {
use super::*;
assert_eq!(format!("{}", UserRead), "0400".to_string());
assert_eq!(format!("{}", UserFile), "0644".to_string());
assert_eq!(format!("{}", UserExec), "0755".to_string());
assert_eq!(format!("{}", UserRWX), "0700".to_string());
assert_eq!(format!("{}", GroupRWX), "0070".to_string());
assert_eq!(format!("{}", OtherRWX), "0007".to_string());
assert_eq!(format!("{}", AllPermissions), "0777".to_string());
assert_eq!(format!("{}", UserRead | UserWrite | OtherWrite), "0602".to_string());
assert_eq!(format!("{}", USER_READ), "0400".to_string());
assert_eq!(format!("{}", USER_FILE), "0644".to_string());
assert_eq!(format!("{}", USER_EXEC), "0755".to_string());
assert_eq!(format!("{}", USER_RWX), "0700".to_string());
assert_eq!(format!("{}", GROUP_RWX), "0070".to_string());
assert_eq!(format!("{}", OTHER_RWX), "0007".to_string());
assert_eq!(format!("{}", ALL_PERMISSIONS), "0777".to_string());
assert_eq!(format!("{}", USER_READ | USER_WRITE | OTHER_WRITE), "0602".to_string());
}
}