fn file_has_write_permission(filepath: &str) -> i32 {
    const USER_BIT:  u32 = 0b10000000;
    const GROUP_BIT: u32 = 0b10000;
    const GUEST_BIT: u32 = 0b10;

    // Collect the mode of permissions for the file
    fs::metadata(filepath).map(|metadata| metadata.permissions().mode()).ok()
        // If the mode is equal to any of the above, return `SUCCESS`
        .map_or(FAILED, |mode| {
            if mode & USER_BIT == USER_BIT || mode & GROUP_BIT == GROUP_BIT ||
                mode & GUEST_BIT == GUEST_BIT { SUCCESS } else { FAILED }
        })
}
/// Exits SUCCESS if the file has write permissions. This function is rather low level because
/// Rust currently does not have a higher level abstraction for obtaining non-standard file modes.
/// To extract the permissions from the mode, the bitwise AND operator will be used and compared
/// with the respective write bits.
Exits SUCCESS if the file has write permissions. This function is rather low level because
Rust currently does not have a higher level abstraction for obtaining non-standard file modes.
To extract the permissions from the mode, the bitwise AND operator will be used and compared
with the respective write bits.
Exits SUCCESS if the file has write permissions . This function is rather low level because Rust currently does not have a higher level abstraction for obtaining non - standard file modes . To extract the permissions from the mode the bitwise AND operator will be used and compared with the respective write bits .
fn file_has_write_permission(filepath: &str) -> i32 {
    const USER_BIT:  u32 = 0b10000000;
    const GROUP_BIT: u32 = 0b10000;
    const GUEST_BIT: u32 = 0b10;
    // Collect the mode of permissions for the file
    fs::metadata(filepath).map(|metadata| metadata.permissions().mode()).ok()
        // If the mode is equal to any of the above, return `SUCCESS`
        .map_or(FAILED, |mode| {
            if mode & USER_BIT == USER_BIT || mode & GROUP_BIT == GROUP_BIT ||
                mode & GUEST_BIT == GUEST_BIT { SUCCESS } else { FAILED }
        })
}
fn file_has_write_permission ( filepath : & str ) -> i32 { const USER_BIT : u32 = 0b10000000 ; const GROUP_BIT : u32 = 0b10000 ; const GUEST_BIT : u32 = 0b10 ; // Collect the mode of permissions for the file fs :: metadata ( filepath ) . map ( | metadata | metadata . permissions ( ) . mode ( ) ) . ok ( ) // If the mode is equal to any of the above, return `SUCCESS` . map_or ( FAILED , | mode | { if mode & USER_BIT == USER_BIT || mode & GROUP_BIT == GROUP_BIT || mode & GUEST_BIT == GUEST_BIT { SUCCESS } else { FAILED } } ) }
Exits SUCCESS if the file has write permissions.
Exits SUCCESS if the file has write permissions .
filepath
&str