[PATCH] D40606: [Support/TarWriter] - Don't allow TarWriter to add the same file more than once.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 03:05:38 PST 2017
grimar updated this revision to Diff 124901.
grimar marked 4 inline comments as done.
grimar edited the summary of this revision.
grimar added a comment.
- Addressed review comments.
https://reviews.llvm.org/D40606
Files:
include/llvm/Support/TarWriter.h
lib/Support/TarWriter.cpp
Index: lib/Support/TarWriter.cpp
===================================================================
--- lib/Support/TarWriter.cpp
+++ lib/Support/TarWriter.cpp
@@ -173,6 +173,10 @@
// Write Path and Data.
std::string Fullpath = BaseDir + "/" + sys::path::convert_to_slash(Path);
+ // We do not want to include the same file more than once.
+ if (!Files.insert(Fullpath).second)
+ return;
+
StringRef Prefix;
StringRef Name;
if (splitUstar(Fullpath, Prefix, Name)) {
Index: include/llvm/Support/TarWriter.h
===================================================================
--- include/llvm/Support/TarWriter.h
+++ include/llvm/Support/TarWriter.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
+#include <set>
namespace llvm {
class TarWriter {
@@ -26,6 +27,7 @@
TarWriter(int FD, StringRef BaseDir);
raw_fd_ostream OS;
std::string BaseDir;
+ std::set<std::string> Files;
};
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40606.124901.patch
Type: text/x-patch
Size: 995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/a3450165/attachment.bin>
More information about the llvm-commits
mailing list