Browse Source

Merge topic 'dot-dir'

830a7d8803 cmArchiveWrite: Remove ./ suffix from zip archives

Acked-by: Kitware Robot <[email protected]>
Merge-request: !4288
Brad King 5 years ago
parent
commit
ee5edfbda2
1 changed files with 7 additions and 2 deletions
  1. 7 2
      Source/cmArchiveWrite.cxx

+ 7 - 2
Source/cmArchiveWrite.cxx

@@ -200,8 +200,10 @@ bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix,
 bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix,
                              bool recursive)
 {
-  if (!this->AddFile(path, skip, prefix)) {
-    return false;
+  if (strcmp(path, ".") != 0 || this->Format != "zip") {
+    if (!this->AddFile(path, skip, prefix)) {
+      return false;
+    }
   }
   if ((!cmSystemTools::FileIsDirectory(path) || !recursive) ||
       cmSystemTools::FileIsSymlink(path)) {
@@ -210,6 +212,9 @@ bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix,
   cmsys::Directory d;
   if (d.Load(path)) {
     std::string next = cmStrCat(path, '/');
+    if (next == "./" && this->Format == "zip") {
+      next.clear();
+    }
     std::string::size_type end = next.size();
     unsigned long n = d.GetNumberOfFiles();
     for (unsigned long i = 0; i < n; ++i) {