# Need help extracting ZIP contents

**URL:** <https://users.rust-lang.org/t/need-help-extracting-zip-contents/51693>\
**Category:** help\
**Created:** [November 19, 2020, 8:58pm UTC](https://users.rust-lang.org/t/need-help-extracting-zip-contents/51693 "2020-11-19T20:58:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RustyOldMan](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/rustyoldman/32/15265_2.png) [@RustyOldMan](https://users.rust-lang.org/u/RustyOldMan)\
**Post date:** [November 19, 2020, 8:58pm UTC](https://users.rust-lang.org/t/need-help-extracting-zip-contents/51693/1 "2020-11-19T20:58:49Z")

</div>

I have a complex file read issue....I have a need to read a DOCX file with an embedded file system, extract a ZIP file, and peruse the ZIP file's internal directory to extract the actual files I need. I already have written this code in Java successfully, so I know it can be accomplished. But, I want to do this in Rust.

Currently, I can read the DOCX file, iterate through the OLE10 objects to locate the file I need. The OLE10 file (which is actually the ZIP) has a weird header of 256 bytes, which I seek past. If I read the rest of the file stream and write it to the filesystem it will write out as a ZIP. I can use 7-zip to open the file and see all the contents.

The problem is, no matter what Rust ZIP crate I use (zip, zip\_extract, zip\_extensions, rc-zip) I just cannot extract the ZIP contents. I continuously run into an issue "cannot find end of central directory". I have iterated through the file, and the EOCD tag of "50 4B 05 06" is actually there. If I end the stream at the EOCD, I got an "early end of file exit" error.

Anyone have any ideas how to use Rust to extract the ZIP directory and attach it to a buffer or the filesystem?

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [February 17, 2021, 8:58pm UTC](https://users.rust-lang.org/t/need-help-extracting-zip-contents/51693/2 "2021-02-17T20:58:57Z")

</div>

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
