summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/TarWriter.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-01-09 01:47:15 +0000
committerRui Ueyama <ruiu@google.com>2017-01-09 01:47:15 +0000
commit3e6490399e0ac56d25819470ed7e53017f25351e (patch)
treeae0c74ada8542888d7511cc3a571d0b38079e8c4 /llvm/lib/Support/TarWriter.cpp
parentec1c75e059a9917651ca39b60d58d41c8e7aecc5 (diff)
downloadbcm5719-llvm-3e6490399e0ac56d25819470ed7e53017f25351e.tar.gz
bcm5719-llvm-3e6490399e0ac56d25819470ed7e53017f25351e.zip
Define sys::path::convert_to_slash
This patch moves convertToUnixPathSeparator from LLD to LLVM. Differential Revision: https://reviews.llvm.org/D28444 llvm-svn: 291414
Diffstat (limited to 'llvm/lib/Support/TarWriter.cpp')
-rw-r--r--llvm/lib/Support/TarWriter.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/llvm/lib/Support/TarWriter.cpp b/llvm/lib/Support/TarWriter.cpp
index 57a4c8f4fc0..f79b364dc1f 100644
--- a/llvm/lib/Support/TarWriter.cpp
+++ b/llvm/lib/Support/TarWriter.cpp
@@ -26,6 +26,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
using namespace llvm;
@@ -147,15 +148,6 @@ static void writeUstarHeader(raw_fd_ostream &OS, StringRef Path, size_t Size) {
OS << StringRef(reinterpret_cast<char *>(&Hdr), sizeof(Hdr));
}
-// We want to use '/' as a path separator even on Windows.
-// This function canonicalizes a given path.
-static std::string canonicalize(std::string S) {
-#ifdef LLVM_ON_WIN32
- std::replace(S.begin(), S.end(), '\\', '/');
-#endif
- return S;
-}
-
// Creates a TarWriter instance and returns it.
Expected<std::unique_ptr<TarWriter>> TarWriter::create(StringRef OutputPath,
StringRef BaseDir) {
@@ -171,7 +163,7 @@ TarWriter::TarWriter(int FD, StringRef BaseDir)
// Append a given file to an archive.
void TarWriter::append(StringRef Path, StringRef Data) {
// Write Path and Data.
- std::string S = BaseDir + "/" + canonicalize(Path) + "\0";
+ std::string S = BaseDir + "/" + sys::path::convert_to_slash(Path) + "\0";
if (fitsInUstar(S)) {
writeUstarHeader(OS, S, Data.size());
} else {
OpenPOWER on IntegriCloud