Add Root() to Fs interface

This commit is contained in:
Nick Craig-Wood 2015-09-01 20:45:27 +01:00
parent cbc6bf6a89
commit 92745aa950
8 changed files with 47 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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 == "" {

View File

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

View File

@ -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 == "" {

View File

@ -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 == "" {