Bladeren bron

gh-2363 zip files in local directory cause eclcc to assert

The code that added support for using paths within zip files
and other archives for ecl include can cause an assert error from
eclcc if there are zip files in the current directory (or another
directory mentioned in the path), as it was trying (but failing) to
treat such zip files as directories to be added to the scope as
modules.

Fixes gh-2363.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 13 jaren geleden
bovenliggende
commit
19682ebf10
1 gewijzigde bestanden met toevoegingen van 24 en 10 verwijderingen
  1. 24 10
      common/remote/hooks/libarchive/archive.cpp

+ 24 - 10
common/remote/hooks/libarchive/archive.cpp

@@ -369,18 +369,32 @@ static IFile *createIFileInArchive(const char *containedFileName)
     StringBuffer fname(containedFileName);
     assertex(fname.length());
     removeTrailingPathSepChar(fname);
-    StringBuffer dirPath, dirTail;
-    splitFilename(fname.str(), &dirPath, &dirPath, &dirTail, &dirTail);
-
-    Owned<IDirectoryIterator> dir = createArchiveDirectoryIterator(dirPath.str(), dirTail.str(), false, true);
-    if (dir->first())
-    {
-        Linked<IFile> file = &dir->query();
-        assertex(!dir->next());
-        return file.getClear();
+    StringAttr container, option, relpath;
+    splitArchivedFileName(fname.str(), container, option, relpath);
+    if (relpath.length())
+    {
+        StringBuffer dirPath, dirTail;
+        dirPath.append(container).append(option);
+        splitFilename(relpath, &dirPath, &dirPath, &dirTail, &dirTail);
+        Owned<IDirectoryIterator> dir = createArchiveDirectoryIterator(dirPath.str(), dirTail.str(), false, true);
+        if (dir->first())
+        {
+            Linked<IFile> file = &dir->query();
+            assertex(!dir->next());
+            return file.getClear();
+        }
+        else
+            return new ArchiveFile(containedFileName, NULL);
     }
     else
-        return new ArchiveFile(containedFileName, NULL);
+    {
+        // Create an IFile representing the root of the archive as a directory
+        struct archive_entry *rootEntry = archive_entry_new();
+        archive_entry_set_pathname(rootEntry, ".");
+        archive_entry_set_mode(rootEntry, __S_IFDIR);
+        archive_entry_set_size(rootEntry, 0);
+        return new ArchiveFile(containedFileName, new ArchiveEntry(rootEntry));
+    }
 }
 
 class ArchiveDirectoryIterator : public CInterface, implements IDirectoryIterator