mirror of
https://github.com/rclone/rclone.git
synced 2025-12-15 15:53:41 +00:00
vfs: add --dir-perms and --file-perms flags - fixes #2897
This allows files to be shown with the execute bit which allows binaries to be run under Windows and Linux.
This commit is contained in:
34
vfs/vfsflags/filemode.go
Normal file
34
vfs/vfsflags/filemode.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package vfsflags
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// 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 errors.Wrap(err, "Bad FileMode - must be octal digits")
|
||||
}
|
||||
*x.Mode = (os.FileMode)(i)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Type of the value
|
||||
func (x *FileMode) Type() string {
|
||||
return "int"
|
||||
}
|
||||
Reference in New Issue
Block a user