Skip to content

PKZipUnarchiver does not create intermediate directories for files #1

@nros

Description

@nros

The intermediate files are not created while unzipping files. If the ZIP file contains directories, everything works as expected. But if the ZIP utility has not added entries for the intermediate directories, unzipping fails.

usually common command line tools to create zip files omit adding
directory names to the zip file. They are not necessary because
non empty directories can be derived from the file paths.

Previous unzipping in PKZipUnarchiver failed to unzip files if
the directories are not present in the ZIP file. Thus zipping on
the command line under Windows/Linux/MacOS produced an
incompatible ZIP file, espacially if just some files are added
to the ZIP file for incremental updates instead of the whole
directory.

This fix forces the creation of directories prior to unzipping
the files.

Signed-off-by: nros nros@nexxar.com

PKToolbox/Sources/Foundation/PKZipUnarchiver.m | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/PKToolbox/Sources/Foundation/PKZipUnarchiver.m b/PKToolbox/Sources/Foundation/PKZipUnarchiver.m
index aa61991..9202d6a 100644
--- a/PKToolbox/Sources/Foundation/PKZipUnarchiver.m
+++ b/PKToolbox/Sources/Foundation/PKZipUnarchiver.m
@@ -76,6 +76,11 @@
attributes:nil
error:outError];
} else {

  •        [fileManager createDirectoryAtPath:[currentFilePath stringByDeletingLastPathComponent]
    
  •               withIntermediateDirectories:YES
    
  •                                attributes:nil
    
  •                                     error:outError];
    
    •    [fileManager createFileAtPath:currentFilePath
                              contents:nil
                            attributes:nil];
      
    -- 1.7.5.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions