diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-09-11 20:30:02 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-09-11 20:30:02 +0000 |
commit | 281f23adc1b76136efd11a410532d0600f6936e8 (patch) | |
tree | ae883405160167f575c58b2c8972734daeda139b /llvm/lib/Support/Path.cpp | |
parent | 40a069adcdcb64a3974315ca2231ce6d62e96776 (diff) | |
download | bcm5719-llvm-281f23adc1b76136efd11a410532d0600f6936e8.tar.gz bcm5719-llvm-281f23adc1b76136efd11a410532d0600f6936e8.zip |
Misc cleanups to the FileSytem api.
The main difference is the removal of
std::error_code exists(const Twine &path, bool &result);
It was an horribly redundant interface since a file not existing is also a valid
error_code. Now we have an access function that returns just an error_code. This
is the only function that has to be implemented for Unix and Windows. The
functions can_write, exists and can_execute an now just wrappers.
One still has to be very careful using these function to avoid introducing
race conditions (Time of check to time of use).
llvm-svn: 217625
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index bdaa12820b8..ef75fc1cd83 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -210,13 +210,13 @@ retry_random_path: } case FS_Name: { - bool Exists; - std::error_code EC = sys::fs::exists(ResultPath.begin(), Exists); + std::error_code EC = + sys::fs::access(ResultPath.begin(), sys::fs::AccessMode::Exist); + if (EC == errc::no_such_file_or_directory) + return std::error_code(); if (EC) return EC; - if (Exists) - goto retry_random_path; - return std::error_code(); + goto retry_random_path; } case FS_Dir: { |