fn mode_to_permissions(array: &[u8]) -> &str {
    // 4-bits: object type (reg, symlink, gitlink)
    // 3-bits: unused
    // 9-bit: permissions (755 or 644)
    // Since the only valid values for the first permission octal are 7 and 6 (111 or 110),
    // we only need the third byte to figure out the permissions
    // 1: type; 2: 000x; 3: xxxx; 4: xxxx
    // 644 => 110 100 100 => 1_1010_0100
    // 755 => 111 101 101 => 1_1110_1101
    if array[1] == 0b1010_0100 {
        "644"
    } else {
        "755"
    }
}
/// Takes last 2 bytes of permissions and returns the file permissions
Takes last 2 bytes of permissions and returns the file permissions
Takes last 2 bytes of permissions and returns the file permissions
fn mode_to_permissions(array: &[u8]) -> &str {
    // 4-bits: object type (reg, symlink, gitlink)
    // 3-bits: unused
    // 9-bit: permissions (755 or 644)
    // Since the only valid values for the first permission octal are 7 and 6 (111 or 110),
    // we only need the third byte to figure out the permissions
    // 1: type; 2: 000x; 3: xxxx; 4: xxxx
    // 644 => 110 100 100 => 1_1010_0100
    // 755 => 111 101 101 => 1_1110_1101
    if array[1] == 0b1010_0100 {
        "644"
    } else {
        "755"
    }
}
fn mode_to_permissions ( array : & [ u8 ] ) -> & str { // 4-bits: object type (reg, symlink, gitlink) // 3-bits: unused // 9-bit: permissions (755 or 644) // Since the only valid values for the first permission octal are 7 and 6 (111 or 110), // we only need the third byte to figure out the permissions // 1: type; 2: 000x; 3: xxxx; 4: xxxx // 644 => 110 100 100 => 1_1010_0100 // 755 => 111 101 101 => 1_1110_1101 if array [ 1 ] == 0b1010_0100 { " " } else { " " } }
Takes last 2 bytes of permissions and returns the file permissions
Takes last 2 bytes of permissions and returns the file permissions
array
&[u8]
array
&[u8]