]> granicus.if.org Git - clang/commitdiff
Replace use of chdir with llvm::sys::fs::set_current_path
authorPavel Labath <labath@google.com>
Tue, 24 Jan 2017 11:14:29 +0000 (11:14 +0000)
committerPavel Labath <labath@google.com>
Tue, 24 Jan 2017 11:14:29 +0000 (11:14 +0000)
NFCI

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292914 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/VirtualFileSystem.cpp

index 50fcb22faf532f2bdfe5d08bd3ae0f06906b75c9..9e13bf7cd5434dcc05c95cae9ba97ebbb1cee8ff 100644 (file)
 #include <memory>
 #include <utility>
 
-// For chdir.
-#ifdef LLVM_ON_WIN32
-#  include <direct.h>
-#else
-#  include <unistd.h>
-#endif
-
 using namespace clang;
 using namespace clang::vfs;
 using namespace llvm;
@@ -235,11 +228,7 @@ std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
   // difference for example on network filesystems, where symlinks might be
   // switched during runtime of the tool. Fixing this depends on having a
   // file system abstraction that allows openat() style interactions.
-  SmallString<256> Storage;
-  StringRef Dir = Path.toNullTerminatedStringRef(Storage);
-  if (int Err = ::chdir(Dir.data()))
-    return std::error_code(Err, std::generic_category());
-  return std::error_code();
+  return llvm::sys::fs::set_current_path(Path);
 }
 
 IntrusiveRefCntPtr<FileSystem> vfs::getRealFileSystem() {