mirror of
https://github.com/rclone/rclone.git
synced 2024-12-22 15:11:56 +01:00
fs: add OverrideDirectory for overriding path of directory
This commit is contained in:
parent
6859c04772
commit
43fa256d56
34
fs/override_dir.go
Normal file
34
fs/override_dir.go
Normal file
@ -0,0 +1,34 @@
|
||||
package fs
|
||||
|
||||
// OverrideDirectory is a wrapper to override the Remote for an
|
||||
// Directory
|
||||
type OverrideDirectory struct {
|
||||
Directory
|
||||
remote string
|
||||
}
|
||||
|
||||
// NewOverrideDirectory returns an OverrideDirectoryObject which will
|
||||
// return the remote specified
|
||||
func NewOverrideDirectory(oi Directory, remote string) *OverrideDirectory {
|
||||
// re-wrap an OverrideDirectory
|
||||
if or, ok := oi.(*OverrideDirectory); ok {
|
||||
return &OverrideDirectory{
|
||||
Directory: or.Directory,
|
||||
remote: remote,
|
||||
}
|
||||
}
|
||||
return &OverrideDirectory{
|
||||
Directory: oi,
|
||||
remote: remote,
|
||||
}
|
||||
}
|
||||
|
||||
// Remote returns the overridden remote name
|
||||
func (o *OverrideDirectory) Remote() string {
|
||||
return o.remote
|
||||
}
|
||||
|
||||
// String returns the overridden remote name
|
||||
func (o *OverrideDirectory) String() string {
|
||||
return o.remote
|
||||
}
|
4
fs/override_dir_test.go
Normal file
4
fs/override_dir_test.go
Normal file
@ -0,0 +1,4 @@
|
||||
package fs
|
||||
|
||||
// Check interfaces satisfied
|
||||
var _ Directory = (*OverrideDirectory)(nil)
|
Loading…
Reference in New Issue
Block a user