diff --git a/drive/drive.go b/drive/drive.go index 30430c474..37c099adc 100644 --- a/drive/drive.go +++ b/drive/drive.go @@ -160,6 +160,11 @@ func (f *FsDrive) Name() string { return f.name } +// The root of the remote (as passed into NewFs) +func (f *FsDrive) Root() string { + return f.root +} + // String converts this FsDrive to a string func (f *FsDrive) String() string { return fmt.Sprintf("Google drive root '%s'", f.root) diff --git a/dropbox/dropbox.go b/dropbox/dropbox.go index 391a4aa8e..083fc9df2 100644 --- a/dropbox/dropbox.go +++ b/dropbox/dropbox.go @@ -114,6 +114,11 @@ func (f *FsDropbox) Name() string { return f.name } +// The root of the remote (as passed into NewFs) +func (f *FsDropbox) Root() string { + return f.root +} + // String converts this FsDropbox to a string func (f *FsDropbox) String() string { return fmt.Sprintf("Dropbox root '%s'", f.root) diff --git a/fs/fs.go b/fs/fs.go index 8350bd01b..8e8cbe065 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -70,6 +70,9 @@ type Fs interface { // The name of the remote (as passed into NewFs) Name() string + // The root of the remote (as passed into NewFs) + Root() string + // String returns a description of the FS String() string diff --git a/fs/limited.go b/fs/limited.go index 8f80396c3..06042f7a3 100644 --- a/fs/limited.go +++ b/fs/limited.go @@ -26,6 +26,11 @@ func (f *Limited) Name() string { return f.fs.Name() // return name of underlying remote } +// The root of the remote (as passed into NewFs) +func (f *Limited) Root() string { + return f.fs.Root() // return root of underlying remote +} + // String returns a description of the FS func (f *Limited) String() string { return fmt.Sprintf("%s limited to %d objects", f.fs.String(), len(f.objects)) diff --git a/googlecloudstorage/googlecloudstorage.go b/googlecloudstorage/googlecloudstorage.go index 8ced5a430..f467df81d 100644 --- a/googlecloudstorage/googlecloudstorage.go +++ b/googlecloudstorage/googlecloudstorage.go @@ -149,6 +149,14 @@ func (f *FsStorage) Name() string { return f.name } +// The root of the remote (as passed into NewFs) +func (f *FsStorage) Root() string { + if f.root == "" { + return f.bucket + } + return f.bucket + "/" + f.root +} + // String converts this FsStorage to a string func (f *FsStorage) String() string { if f.root == "" { diff --git a/local/local.go b/local/local.go index 40992382d..f6dae8b99 100644 --- a/local/local.go +++ b/local/local.go @@ -77,6 +77,11 @@ func (f *FsLocal) Name() string { return f.name } +// The root of the remote (as passed into NewFs) +func (f *FsLocal) Root() string { + return f.root +} + // String converts this FsLocal to a string func (f *FsLocal) String() string { return fmt.Sprintf("Local file system at %s", f.root) diff --git a/s3/s3.go b/s3/s3.go index 98c209fee..73c078753 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -158,6 +158,14 @@ func (f *FsS3) Name() string { return f.name } +// The root of the remote (as passed into NewFs) +func (f *FsS3) Root() string { + if f.root == "" { + return f.bucket + } + return f.bucket + "/" + f.root +} + // String converts this FsS3 to a string func (f *FsS3) String() string { if f.root == "" { diff --git a/swift/swift.go b/swift/swift.go index 0e7a368be..5b41fca35 100644 --- a/swift/swift.go +++ b/swift/swift.go @@ -81,6 +81,14 @@ func (f *FsSwift) Name() string { return f.name } +// The root of the remote (as passed into NewFs) +func (f *FsSwift) Root() string { + if f.root == "" { + return f.container + } + return f.container + "/" + f.root +} + // String converts this FsSwift to a string func (f *FsSwift) String() string { if f.root == "" {