1
0
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:
Nick Craig-Wood
2014-05-05 19:52:52 +01:00
parent ca3752f824
commit 99695d57ab
9 changed files with 228 additions and 44 deletions

View File

@@ -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
}