fs/FileSystem: merge CheckAccess() into PathExists()
PathExists() should better do what CheckAccess() does, and CheckAccess() doesn't do what its name implies.
This commit is contained in:
parent
4f0f81a047
commit
4dd861ee23
|
@ -117,7 +117,7 @@ SimpleDatabase::Check(Error &error) const
|
||||||
assert(!path.IsNull());
|
assert(!path.IsNull());
|
||||||
|
|
||||||
/* Check if the file exists */
|
/* Check if the file exists */
|
||||||
if (!CheckAccess(path)) {
|
if (!PathExists(path)) {
|
||||||
/* If the file doesn't exist, we can't check if we can write
|
/* If the file doesn't exist, we can't check if we can write
|
||||||
* it, so we are going to try to get the directory path, and
|
* it, so we are going to try to get the directory path, and
|
||||||
* see if we can write a file in that */
|
* see if we can write a file in that */
|
||||||
|
|
|
@ -122,20 +122,6 @@ CheckAccess(Path path, int mode)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks is specified path exists and accessible.
|
|
||||||
*/
|
|
||||||
static inline bool
|
|
||||||
CheckAccess(Path path)
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
struct stat buf;
|
|
||||||
return StatFile(path, buf);
|
|
||||||
#else
|
|
||||||
return CheckAccess(path, F_OK);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if #Path exists and is a regular file.
|
* Checks if #Path exists and is a regular file.
|
||||||
*/
|
*/
|
||||||
|
@ -160,10 +146,14 @@ DirectoryExists(Path path, bool follow_symlinks = true)
|
||||||
* Checks if #Path exists.
|
* Checks if #Path exists.
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
PathExists(Path path, bool follow_symlinks = true)
|
PathExists(Path path)
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
return StatFile(path, buf, follow_symlinks);
|
return StatFile(path, buf);
|
||||||
|
#else
|
||||||
|
return CheckAccess(path, F_OK);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue