github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/vfs/vfsflags/filemode.go (about) 1 package vfsflags 2 3 import ( 4 "fmt" 5 "os" 6 "strconv" 7 8 "github.com/pkg/errors" 9 ) 10 11 // FileMode is a command line friendly os.FileMode 12 type FileMode struct { 13 Mode *os.FileMode 14 } 15 16 // String turns FileMode into a string 17 func (x *FileMode) String() string { 18 return fmt.Sprintf("0%3o", *x.Mode) 19 } 20 21 // Set a FileMode 22 func (x *FileMode) Set(s string) error { 23 i, err := strconv.ParseInt(s, 8, 64) 24 if err != nil { 25 return errors.Wrap(err, "Bad FileMode - must be octal digits") 26 } 27 *x.Mode = (os.FileMode)(i) 28 return nil 29 } 30 31 // Type of the value 32 func (x *FileMode) Type() string { 33 return "FileMode" 34 }