diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-12-15 01:50:13 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-12-15 01:50:13 +0000 |
commit | c29befb554c025da801737bc86a8215d1dc6038c (patch) | |
tree | c4fe20c6d360ddbc8e7203d8a7b7d95950db9773 /lib/System/Win32/Path.cpp | |
parent | 67f6d3ad30941e0ac6d36939c271eec7d7b8a0e2 (diff) |
For PR351:
* Fix implementation and documentation about LLVMGCCDIR/bytecode-libs
* Add the makeUnique method, replacement for getUniqueFilename in Support.
* Add the sys::CopyFile function, replacement for CopyFile in Support.
* Move GetLLVMConfigDir() into generic code area since its generic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32/Path.cpp')
-rw-r--r-- | lib/System/Win32/Path.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/System/Win32/Path.cpp b/lib/System/Win32/Path.cpp index f6e4c3b476..149b4a1295 100644 --- a/lib/System/Win32/Path.cpp +++ b/lib/System/Win32/Path.cpp @@ -158,7 +158,7 @@ Path::GetBytecodeLibraryPaths(std::vector<sys::Path>& Paths) { } #ifdef LLVMGCCDIR { - Path tmpPath(std::string(LLVMGCCDIR) + "bytecode-libs/"); + Path tmpPath(std::string(LLVMGCCDIR) + "lib/"); if (tmpPath.readable()) Paths.push_back(tmpPath); } @@ -584,6 +584,29 @@ bool Path::getMagicNumber(std::string& Magic, unsigned len) const { return true; } +void +CopyFile(const sys::Path &Dest, const sys::Path &Src) { + if (!::CopyFile(Src.c_str(), Dest.c_str(), false)) + ThrowError("Can't copy '" + Src.toString() + + "' to '" + Dest.toString() + "'"); +} + +void +Path::makeUnique() { + if (!exists()) + return; // File doesn't exist already, just use it! + + Path dir (*this); + dir.elideFile(); + std::string fname = this->getLast(); + + char* newName = alloca(MAX_PATH+1); + if (!GetTempFileName(dir.c_str(), fname.c_str(), 0, newName)) + ThrowError("Cannot make unique filename for '" + path + "'"); + + path = newName; +} + } } |