summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/PathV1.h3
-rw-r--r--lib/Support/PathV2.cpp16
-rw-r--r--lib/Support/Unix/Path.inc3
-rw-r--r--lib/Support/Windows/Path.inc5
4 files changed, 23 insertions, 4 deletions
diff --git a/include/llvm/Support/PathV1.h b/include/llvm/Support/PathV1.h
index b6470795fd..0b8a464713 100644
--- a/include/llvm/Support/PathV1.h
+++ b/include/llvm/Support/PathV1.h
@@ -387,7 +387,8 @@ namespace sys {
/// existing directory.
/// @returns true if the pathname references an existing directory.
/// @brief Determines if the path is a directory in the file system.
- bool isDirectory() const;
+ LLVM_ATTRIBUTE_DEPRECATED(bool isDirectory() const,
+ LLVM_PATH_DEPRECATED_MSG(fs::is_directory));
/// This function determines if the path name references an
/// existing symbolic link.
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp
index 3b232abf7d..f2ca34b4ad 100644
--- a/lib/Support/PathV2.cpp
+++ b/lib/Support/PathV2.cpp
@@ -636,10 +636,26 @@ bool is_directory(file_status status) {
return status.type() == file_type::directory_file;
}
+error_code is_directory(const Twine &path, bool &result) {
+ file_status st;
+ if (error_code ec = status(path, st))
+ return ec;
+ result = is_directory(st);
+ return success;
+}
+
bool is_regular_file(file_status status) {
return status.type() == file_type::regular_file;
}
+error_code is_regular_file(const Twine &path, bool &result) {
+ file_status st;
+ if (error_code ec = status(path, st))
+ return ec;
+ result = is_regular_file(st);
+ return success;
+}
+
bool is_symlink(file_status status) {
return status.type() == file_type::symlink_file;
}
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
index b39e465a53..bdd13a64b0 100644
--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -823,7 +823,8 @@ Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
Buf.resize(path.size()+8);
char *FNBuffer = &Buf[0];
path.copy(FNBuffer,path.size());
- if (isDirectory())
+ bool isdir;
+ if (!fs::is_directory(path, isdir) && isdir)
strcpy(FNBuffer+path.size(), "/XXXXXX");
else
strcpy(FNBuffer+path.size(), "-XXXXXX");
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index 9100739ae0..625f67aa91 100644
--- a/lib/Support/Windows/Path.inc
+++ b/lib/Support/Windows/Path.inc
@@ -410,9 +410,10 @@ Path::canExecute() const {
bool
Path::isRegularFile() const {
- if (isDirectory())
+ bool res;
+ if (fs::is_regular_file(path, res))
return false;
- return true;
+ return res;
}
StringRef