What exactly happens when a ZIP file is extracted?

454 viewsOtherTechnology

I know the structure of a ZIP file, but how does a computer go about reassembling it into a directory? I’m not asking about compression algorithms, what I mean is in what order does it decompress the files, and in what order does it write them to storage?

In: Technology

4 Answers

Anonymous 0 Comments

There’s an entry in the zip file for every file or folder and the extraction software can also figure out the structure from file names : for example if an entry has the name “folder/filename.txt” the software recognizes / character as folder separator and knows it needs to create.the folder “folder” if it does not exist, and put “filename.txt” inside that folder.

Fun fact zip files allow paths like “../../../folder1/folder2/file.extension” which would allow writing files outside the folder a user specifies, but most decompression programs will refuse to write outside specified destination folder and either not create file or ‘flatten’ the path (pretend the “go up one level” notation “..” doesn’t exist)

The decompression program.will .read.the records.at.the end of the file and will usually extract the files sequentially, as the records are read. Some programs may detect if two or more records point to same file name and skip writing the data associated with first records to disk as it would be overwritten later anyway. It’s also possible to have empty spaces in zip archives, as a result of deleting entries in the zip file.

You are viewing 1 out of 4 answers, click here to view all answers.