Skip to content

Cannot create dir from full Windows path #369

@tamasszarka

Description

@tamasszarka

This seems to be a bug.
When extracting an archive, directory creation fails when a subdirectory is to be extracted, but its parent directory in the archive has not yet been created. On the below exawmple structue, this issue occurs when trying to extract file_x earlier than file_y.

Example - extracting the below archive into d:\temp:
/dir1/
/subdir1/
/subdir1/file_x
/file_y
/dir2/

What specifically happens is that as the mz_dir_make function in mz_os.c runs to create the directory dir1/subdir1 for file_x on the file system, it goes ahead and breaks down the full Windows path d:\temp\dir1\subdir1 to components to be able to create it level-by-level, and it breaks it up based on path-separators (obviously), attempting to create them in this order:
d:
d:\temp
d:\temp\dir1
d:\temp\dir1\subdir1

That's to logic at least - but the first iteration fails, as CreateDirectoryW in mz_os_win32.c yields ERROR_ACCESS_DENIED for a drive letter, preventing the loop from continuing with the iteration on the target path, and ends up returning MZ_INTERNAL_ERROR from mz_zip_reader_save_all.

This is specific to Windows and to archives where subdirs occur before files on the same level inside a directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedIssue or bug has been fixed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions