mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 18:31:17 +08:00
FileExists check if a file exists
This commit is contained in:
parent
31d2fb4e11
commit
7ae7080824
13
fs/fs.go
13
fs/fs.go
|
@ -733,3 +733,16 @@ func CheckClose(c io.Closer, err *error) {
|
|||
*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…
Reference in New Issue
Block a user