mirror of
https://github.com/rclone/rclone.git
synced 2026-01-06 02:23:24 +00:00
Implement single file operations for all file systems
This commit is contained in:
@@ -45,6 +45,16 @@ type FsObjectLocal struct {
|
||||
func NewFs(name, root string) (fs.Fs, error) {
|
||||
root = path.Clean(root)
|
||||
f := &FsLocal{root: root}
|
||||
// Check to see if this points to a file
|
||||
fi, err := os.Lstat(f.root)
|
||||
if err == nil && fi.Mode().IsRegular() {
|
||||
// It is a file, so use the parent as the root
|
||||
remote := path.Base(root)
|
||||
f.root = path.Dir(root)
|
||||
obj := f.NewFsObject(remote)
|
||||
// return a Fs Limited to this object
|
||||
return fs.NewLimited(f, obj), nil
|
||||
}
|
||||
return f, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user