Remove sys::CopyFile.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 12 Jun 2013 14:16:52 +0000 (14:16 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 12 Jun 2013 14:16:52 +0000 (14:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183831 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 232167a6ca552a254397b1ff14695bc40979bc70..5ed9c9fd2fee6a904b8bac2bddb350f0f17263f9 100644 (file)
@@ -592,12 +592,6 @@ namespace sys {
     /// @}
   };
 
-  /// This function can be used to copy the file specified by Src to the
-  /// file specified by Dest. If an error occurs, Dest is removed.
-  /// @returns true if an error occurs, false otherwise
-  /// @brief Copy one file to another.
-  bool CopyFile(const Path& Dest, const Path& Src, std::string* ErrMsg);
-
   /// This is the OS-specific path separator: a colon on Unix or a semicolon
   /// on Windows.
   extern const char PathSeparator;
index 7b236a56e11829469b819b06d0fbe199cc45a477..b17b9f91dec711cc3278d0f2e9bad2e5fb9c498d 100644 (file)
@@ -666,53 +666,6 @@ Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrStr) const {
   return false;
 }
 
-bool
-sys::CopyFile(const sys::Path &Dest, const sys::Path &Src, std::string* ErrMsg){
-  int inFile = -1;
-  int outFile = -1;
-  inFile = ::open(Src.c_str(), O_RDONLY);
-  if (inFile == -1)
-    return MakeErrMsg(ErrMsg, Src.str() +
-      ": can't open source file to copy");
-
-  outFile = ::open(Dest.c_str(), O_WRONLY|O_CREAT, 0666);
-  if (outFile == -1) {
-    ::close(inFile);
-    return MakeErrMsg(ErrMsg, Dest.str() +
-      ": can't create destination file for copy");
-  }
-
-  char Buffer[16*1024];
-  while (ssize_t Amt = ::read(inFile, Buffer, 16*1024)) {
-    if (Amt == -1) {
-      if (errno != EINTR && errno != EAGAIN) {
-        ::close(inFile);
-        ::close(outFile);
-        return MakeErrMsg(ErrMsg, Src.str()+": can't read source file");
-      }
-    } else {
-      char *BufPtr = Buffer;
-      while (Amt) {
-        ssize_t AmtWritten = ::write(outFile, BufPtr, Amt);
-        if (AmtWritten == -1) {
-          if (errno != EINTR && errno != EAGAIN) {
-            ::close(inFile);
-            ::close(outFile);
-            return MakeErrMsg(ErrMsg, Dest.str() +
-              ": can't write destination file");
-          }
-        } else {
-          Amt -= AmtWritten;
-          BufPtr += AmtWritten;
-        }
-      }
-    }
-  }
-  ::close(inFile);
-  ::close(outFile);
-  return false;
-}
-
 bool
 Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
   bool Exists;
index f4a2a1b447111450bc754aaebfb027434328bfd1..734e6f50d80b8cfa65ed8bed4412dd831f52e9ea 100644 (file)
@@ -21,7 +21,6 @@
 #include <malloc.h>
 
 // We need to undo a macro defined in Windows.h, otherwise we won't compile:
-#undef CopyFile
 #undef GetCurrentDirectory
 
 // Windows happily accepts either forward or backward slashes, though any path
@@ -730,16 +729,6 @@ Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrMsg) const {
   return false;
 }
 
-bool
-CopyFile(const sys::Path &Dest, const sys::Path &Src, std::string* ErrMsg) {
-  // Can't use CopyFile macro defined in Windows.h because it would mess up the
-  // above line.  We use the expansion it would have in a non-UNICODE build.
-  if (!::CopyFileA(Src.c_str(), Dest.c_str(), false))
-    return MakeErrMsg(ErrMsg, "Can't copy '" + Src.str() +
-               "' to '" + Dest.str() + "': ");
-  return false;
-}
-
 bool
 Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
   bool Exists;