rclone/vfs/vfsflags/filemode.go
Nick Craig-Wood e43b5ce5e5 Remove github.com/pkg/errors and replace with std library version
This is possible now that we no longer support go1.12 and brings
rclone into line with standard practices in the Go world.

This also removes errors.New and errors.Errorf from lib/errors and
prefers the stdlib errors package over lib/errors.
2021-11-07 11:53:30 +00:00

33 lines
571 B
Go

package vfsflags
import (
"fmt"
"os"
"strconv"
)
// FileMode is a command line friendly os.FileMode
type FileMode struct {
Mode *os.FileMode
}
// String turns FileMode into a string
func (x *FileMode) String() string {
return fmt.Sprintf("0%3o", *x.Mode)
}
// Set a FileMode
func (x *FileMode) Set(s string) error {
i, err := strconv.ParseInt(s, 8, 64)
if err != nil {
return fmt.Errorf("Bad FileMode - must be octal digits: %w", err)
}
*x.Mode = (os.FileMode)(i)
return nil
}
// Type of the value
func (x *FileMode) Type() string {
return "FileMode"
}