mirror of
https://github.com/rclone/rclone.git
synced 2025-12-12 06:24:14 +01:00
FileExists check if a file exists
This commit is contained in:
committed by
Nick Craig-Wood
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
|
*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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user