Can't distinguish between files and directories with the same name that are extracted?
San-greal opened this issue · 1 comments
San-greal commented
The zip format file is generated with the following code:
let path = Path::new("test.zip");
let file = File::create(path).unwrap();
let mut zip = ZipWriter::new(file);
let options = FileOptions::default().compression_method(Zstd);
zip.start_file("test", options).unwrap();
zip.write_all(b"Hello, World!\n").unwrap();
zip.write_all(b"Hello, World!\n").unwrap();
zip.add_directory("test/test1", options).unwrap();
zip.finish().unwrap();
The unzip operation is performed by:
let mut file = File::open("test.zip").unwrap();
let mut archive = zip::ZipArchive::new(file).unwrap();
archive.extract("C:\\Users\\Desktop\\untitled\\src").unwrap();
So the following results appear:
There is no problem when the directory created is not test/test1
, for example a/test1
is correct. Is this caused by the inability to distinguish between files and directories?
ryanavella commented
Am I understanding correctly that the error only happens during unzipping, when trying to create both a test
file and a test/
directory?
I'm fairly certain most mainstream OS+filesystem combinations don't allow this. On Unix-like systems, directories are just another kind of file, so this would be like trying to name two files the same thing.