1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-12-22 13:56:30 +00:00

Merge pull request #25 from stephen679/get_all_mode_bits

keywords: obtain all permission bits
This commit is contained in:
Vincent Batts 2016-07-20 04:40:32 +09:00 committed by GitHub
commit 460fce6502

View file

@ -166,7 +166,17 @@ var (
var (
modeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
return fmt.Sprintf("mode=%#o", info.Mode().Perm()), nil
permissions := info.Mode().Perm()
if os.ModeSetuid&info.Mode() > 0 {
permissions |= (1 << 11)
}
if os.ModeSetgid&info.Mode() > 0 {
permissions |= (1 << 10)
}
if os.ModeSticky&info.Mode() > 0 {
permissions |= (1 << 9)
}
return fmt.Sprintf("mode=%#o", permissions), nil
}
sizeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
return fmt.Sprintf("size=%d", info.Size()), nil