Support/Path: Deprecate PathV1::isDirectory and replace all uses with PathV2::is_dire...
authorMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 11 Jan 2011 01:21:55 +0000 (01:21 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 11 Jan 2011 01:21:55 +0000 (01:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123209 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PathV1.h
lib/Support/PathV2.cpp
lib/Support/Unix/Path.inc
lib/Support/Windows/Path.inc

index b6470795fd7a2bff78e2ed033074092439d46023..0b8a4647131477c946e9be72acb6bbd7c614cdf2 100644 (file)
@@ -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.
index 3b232abf7d00e7edfccfdcb1019268522d327971..f2ca34b4adf1bb63e3c06ffd17149c12ea2e4dc1 100644 (file)
@@ -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;
 }
index b39e465a5359c1de90b55e5f704c56bf8baf7ca8..bdd13a64b01594e4c9d3de037b5cb3fc6b45ef46 100644 (file)
@@ -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");
index 9100739ae0d9524d0b7c5c076a69cc03e712f364..625f67aa912a8e2c400d44669d4b6291326c502a 100644 (file)
@@ -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