Sagar
Sagar

Reputation: 105

how to zip empty folders in File manager in iOS?

I am developing a app like file manager. In this i have created zip folder using any existing folder, it works perfectly fine. For this i have used SSZipArchive API. After zip i send it through mail. It's working fine too.

Now when i try to zip any empty folder, it is not working. Means empty folder does not zip.

Upvotes: 0

Views: 423

Answers (2)

0xFADE
0xFADE

Reputation: 832

Isn't a standard thing to have stub files in directories like that. Some file with no contents.

Upvotes: 0

trojanfoe
trojanfoe

Reputation: 122391

Yeah looking at the source code, the method + createZipFileAtPath:withContentsOfDirectory: only appears to care about files:

while ((fileName = [dirEnumerator nextObject])) {
    BOOL isDir;
    NSString *fullFilePath = [directoryPath stringByAppendingPathComponent:fileName];
    [fileManager fileExistsAtPath:fullFilePath isDirectory:&isDir];
    if (!isDir) {
        [zipArchive writeFileAtPath:fullFilePath withFileName:fileName];
    }
}

You have two choices:

  1. Fix it yourself and then send a pull request to the author on github and contribute to work you have, yourself, benefited from.
  2. Live with it. It's not clear how an empty folder not appearing in the zip file is an issue anyway.

Upvotes: 0

Related Questions