forked from TrueCloudLab/rclone
FileExists check if a file exists
This commit is contained in:
parent
31d2fb4e11
commit
7ae7080824
1 changed files with 13 additions and 0 deletions
13
fs/fs.go
13
fs/fs.go
|
@ -733,3 +733,16 @@ func CheckClose(c io.Closer, err *error) {
|
||||||
*err = cerr
|
*err = cerr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileExists returns true if a file remote exists.
|
||||||
|
// If remote is a directory, FileExists returns false.
|
||||||
|
func FileExists(fs Fs, remote string) (bool, error) {
|
||||||
|
_, err := fs.NewObject(remote)
|
||||||
|
if err != nil {
|
||||||
|
if err == ErrorObjectNotFound || err == ErrorNotAFile {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue