ZipArchive icon indicating copy to clipboard operation
ZipArchive copied to clipboard

Also Zip directory if use createZipFileAtPath:withFilesAtPaths:withPassword:

Open veila opened this issue 8 years ago • 5 comments

Hi, Like title, when I select more than one file path include file and directory, the directory lose data. And I always move all of them in one temporary directory and zip it. then remove the temporary directory.

veila avatar Sep 26 '17 11:09 veila

Are you using the latest version of ZipArchive? (version 2.0.7 in September 2017)

Can you fork our project and modify either the ObjC example or the Swift example to demonstrate the issue?

Coeur avatar Sep 29 '17 11:09 Coeur

Sorry about non clear question. I mean I hope the ZipArchive can support zip file and directory same time like this method: createZipFileAtPath:withFilesAtPaths:withPassword:.

veila avatar Oct 11 '17 03:10 veila

I see. We could zip directories too with that method, but it would be also nicer to rename it in that case.

Coeur avatar Oct 11 '17 03:10 Coeur

Now I solved this problem by create a temporary directory then copy files and folder which I wanna zip together in the temporary directory, then use createZipFileAtPath:withContentsOfDirectory to compress it.After success I remove the temporary directory. Do you have another better idea?

veila avatar Oct 12 '17 03:10 veila

Your workaround is a valid approach. Another possibility for now would be to detect which entries are directories and then mix some:

  • - (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName withPassword:(nullable NSString *)password;
  • - (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName withPassword:(nullable NSString *)password;

Coeur avatar Oct 12 '17 07:10 Coeur