Commit 389d416b authored by James Johnston's avatar James Johnston
Browse files

SystemTools: Clarify/simplify behavior of FileExists

The FileExists function always ensures that a file is readable on
POSIX systems by using access() with R_OK.  This was due to bug #809.
Publicly state in the header file that this is being done.

Also simplify the implementation so that redundant code handling the
isFile parameter is eliminated.

Change-Id: Ie07bec7aa5dd2bca07bb3244c01c0a29587aa437
parent 8122214c
......@@ -1233,13 +1233,11 @@ bool SystemTools::FileExists(const kwsys_stl::string& filename)
bool SystemTools::FileExists(const char* filename, bool isFile)
// If isFile is set return not FileIsDirectory,
// so this will only be true if it is a file
return !isFile || !SystemTools::FileIsDirectory(filename);
return false;
return false;
return SystemTools::FileExists(kwsys_stl::string(filename), isFile);
......@@ -292,7 +292,9 @@ public:
* Return true if a file exists in the current directory.
* If isFile = true, then make sure the file is a file and
* not a directory. If isFile = false, then return true
* if it is a file or a directory.
* if it is a file or a directory. Note that the file will
* also be checked for read access. (Currently, this check
* for read access is only done on POSIX systems.)
static bool FileExists(const char* filename, bool isFile);
static bool FileExists(const kwsys_stl::string& filename, bool isFile);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment