Support/Path: Deprecate PathV1::exists and replace all uses with PathV2::fs::exists.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 10 Jan 2011 02:34:23 +0000 (02:34 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 10 Jan 2011 02:34:23 +0000 (02:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123151 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PathV1.h
lib/Archive/Archive.cpp
lib/Archive/ArchiveWriter.cpp
lib/CompilerDriver/Main.cpp
lib/Support/Path.cpp
lib/Support/Unix/Path.inc
lib/Support/Unix/Program.inc
lib/Support/Windows/Path.inc
tools/llvm-ar/llvm-ar.cpp
tools/llvm-ranlib/llvm-ranlib.cpp

index 86fdb0c0accb7c6488ce95af6f0ba4f76c46c8d3..b6470795fd7a2bff78e2ed033074092439d46023 100644 (file)
@@ -380,7 +380,8 @@ namespace sys {
       /// directory.
       /// @brief Determines if the path is a file or directory in
       /// the file system.
-      bool exists() const;
+      LLVM_ATTRIBUTE_DEPRECATED(bool exists() const,
+        LLVM_PATH_DEPRECATED_MSG(fs::exists));
 
       /// This function determines if the path name references an
       /// existing directory.
index 20d9deec99ca481cde271e0c2dc9bef0e65138bd..8aa5d5bd77968ce3ee3271c7aeb58cc0248f7060 100644 (file)
@@ -15,6 +15,7 @@
 #include "ArchiveInternals.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Module.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/system_error.h"
@@ -66,8 +67,9 @@ ArchiveMember::ArchiveMember(Archive* PAR)
 // different file, presumably as an update to the member. It also makes sure
 // the flags are reset correctly.
 bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) {
-  if (!newFile.exists()) {
-    if (ErrMsg) 
+  bool Exists;
+  if (sys::fs::exists(newFile.str(), Exists) || !Exists) {
+    if (ErrMsg)
       *ErrMsg = "Can not replace an archive member with a non-existent file";
     return true;
   }
index 07516c6aa45eebf9bc234ce2ef5cfd067796aa46..7499a22878e36eccb56a4b174c9fcf44286ba665 100644 (file)
@@ -15,6 +15,7 @@
 #include "llvm/Module.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
@@ -156,7 +157,8 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr,
 bool
 Archive::addFileBefore(const sys::Path& filePath, iterator where, 
                         std::string* ErrMsg) {
-  if (!filePath.exists()) {
+  bool Exists;
+  if (sys::fs::exists(filePath.str(), Exists) || !Exists) {
     if (ErrMsg)
       *ErrMsg = "Can not add a non-existent file to archive";
     return true;
index 88cfdb21230513e4e7c4b5b5f4369fd736a817ef..7120027f7ce0e84668115eda8862835cdf2ed0d0 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/CompilerDriver/CompilationGraph.h"
 #include "llvm/CompilerDriver/Error.h"
 
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Path.h"
 
@@ -50,7 +51,8 @@ namespace {
       return 0;
     }
 
-    if (!tempDir.exists()) {
+    bool Exists;
+    if (llvm::sys::fs::exists(tempDir.str(), Exists) || !Exists) {
       std::string ErrMsg;
       if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) {
         PrintError(ErrMsg);
index 3e0ee8dd86d07abd9d3ec6171d5e47b3ba9f8d4b..4689208ded31d28dcdb6287cc2e3536b61601bc0 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "llvm/Support/Path.h"
 #include "llvm/Config/config.h"
+#include "llvm/Support/FileSystem.h"
 #include <cassert>
 #include <cstring>
 #include <ostream>
index 886ba6bf6d418e9374e29f244d2cffe4d77a2305..b39e465a5359c1de90b55e5f704c56bf8baf7ca8 100644 (file)
@@ -811,7 +811,8 @@ sys::CopyFile(const sys::Path &Dest, const sys::Path &Src, std::string* ErrMsg){
 
 bool
 Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
-  if (reuse_current && !exists())
+  bool Exists;
+  if (reuse_current && (fs::exists(path, Exists) || !Exists))
     return false; // File doesn't exist already, just use it!
 
   // Append an XXXXXX pattern to the end of the file for use with mkstemp,
index 17c3ba14bc2215eb3ec3060b6f6cac243dc1ea96..1104bc7503e1a0c5005809bde028ea6fa85b4e21 100644 (file)
@@ -17,6 +17,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <llvm/Config/config.h>
+#include "llvm/Support/FileSystem.h"
 #include "Unix.h"
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -355,7 +356,8 @@ Program::Wait(const sys::Path &path,
     // Following the POSIX convention for command-line tools (which posix_spawn
     // itself apparently does not), check to see if the failure was due to some
     // reason other than the file not existing, and return 126 in this case.
-    if (result == 127 && path.exists())
+    bool Exists;
+    if (result == 127 && !llvm::sys::fs::exists(path.str(), Exists) && Exists)
       result = 126;
 #endif
     if (result == 127) {
index cc68b9f3abcb2a63e6ac5501f55e47690df6cea0..9100739ae0d9524d0b7c5c076a69cc03e712f364 100644 (file)
@@ -694,7 +694,8 @@ Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
 
   if (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
     // If it doesn't exist, we're done.
-    if (!exists())
+    bool Exists;
+    if (fs::exists(path, Exists) || !Exists)
       return false;
 
     char *pathname = reinterpret_cast<char *>(_alloca(path.length()+3));
@@ -868,7 +869,8 @@ CopyFile(const sys::Path &Dest, const sys::Path &Src, std::string* ErrMsg) {
 
 bool
 Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
-  if (reuse_current && !exists())
+  bool Exists;
+  if (reuse_current && (fs::exists(path, Exists) || !Exists))
     return false; // File doesn't exist already, just use it!
 
   // Reserve space for -XXXXXX at the end.
@@ -885,7 +887,7 @@ Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
     if (++FCounter > 999999)
       FCounter = 0;
     path = FNBuffer;
-  } while (exists());
+  } while (!fs::exists(path, Exists) && Exists);
   return false;
 }
 
index 3271f7c82f46670635ee43aaf28d681e24582d57..4fbd3bcbd9c8bec5633f4536be450bdfb4e77657 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/Module.h"
 #include "llvm/Bitcode/Archive.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Format.h"
@@ -310,7 +311,8 @@ bool buildPaths(bool checkExistence, std::string* ErrMsg) {
     if (!aPath.set(Members[i]))
       throw std::string("File member name invalid: ") + Members[i];
     if (checkExistence) {
-      if (!aPath.exists())
+      bool Exists;
+      if (sys::fs::exists(aPath.str(), Exists) || !Exists)
         throw std::string("File does not exist: ") + Members[i];
       std::string Err;
       sys::PathWithStatus PwS(aPath);
@@ -715,7 +717,8 @@ int main(int argc, char **argv) {
       throw std::string("Archive name invalid: ") + ArchiveName;
 
     // Create or open the archive object.
-    if (!ArchivePath.exists()) {
+    bool Exists;
+    if (llvm::sys::fs::exists(ArchivePath.str(), Exists) || !Exists) {
       // Produce a warning if we should and we're creating the archive
       if (!Create)
         errs() << argv[0] << ": creating " << ArchivePath.str() << "\n";
index 7f94c2413dbf442927424abc9fcee81e340d775b..64f795f7f63d5ff4a0a88f113cf2b81d38a2de55 100644 (file)
@@ -15,6 +15,7 @@
 #include "llvm/Module.h"
 #include "llvm/Bitcode/Archive.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Format.h"
@@ -69,7 +70,8 @@ int main(int argc, char **argv) {
       throw std::string("Archive name invalid: ") + ArchiveName;
 
     // Make sure it exists, we don't create empty archives
-    if (!ArchivePath.exists())
+    bool Exists;
+    if (llvm::sys::fs::exists(ArchivePath.str(), Exists) || !Exists)
       throw std::string("Archive file does not exist");
 
     std::string err_msg;