rust-cab icon indicating copy to clipboard operation
rust-cab copied to clipboard

support large cab files

Open rmzone opened this issue 5 months ago • 0 comments

I am not able to decompress cab files that have more that 0xffff blocks. A maximum of 0x1ffff blocks is supported though. I'm not sure if this is official or not, but other tools like 7zip and pigz seem to be able to decompress in this case.

For a work around I modified FolderReader::new

// Calculate the real number of blocks, since entry.num_data_blocks is limited to 0xffff.
// The actual maximum supported is 0x1ffff blocks.
let length: usize = entry.files.iter().map(|x| x.uncompressed_size() as usize).sum();
let rem = length % 0x8000;
let num_data_blocks = length / 0x8000 + if rem > 0 { 1 } else { 0 };
let mut data_blocks = Vec::with_capacity(num_data_blocks);

For my use case is for mszip compression. I don't know if this works for other types. I have not tested compressing.

rmzone avatar Aug 07 '25 12:08 rmzone