mirror of
https://github.com/rclone/rclone.git
synced 2024-12-11 09:41:47 +01:00
fdd2f8e6d2
Reported by staticcheck 2022.1.2 (v0.3.2) See: staticcheck.io
33 lines
571 B
Go
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"
|
|
}
|