Comments (5)
I actually just merged a major update today that changes/extends how zips are handled, so make sure you have the latest version.
With the update, this library can read zip entry data from a FolderItem, a MemoryBlock, or from anything else that can be used to construct a Readable object.
For example:
Dim filedata As String = "Hello, world!"
Dim filestream As New BinaryStream(filedata) ' BinaryStream implements Readable
Dim writer As New PKZip.ZipWriter
writer.AppendEntry("HelloWord2.txt", filestream, filestream.Length)
writer.Commit(SpecialFolder.Desktop.Child("test.zip"))
Wiki reference:
from rb-zlib.
Unfortunately 64 bit builds are not yet supported. Clearing this compile error may allow you to build, but the zlib functions are expecting a 32-bit binary interface and may fail in interesting and destructive ways on 64-bit. That being said, I was able to clear the error by changing UInt32(32 * 8)
to (32 * 8)
.
64-bit compatibility is something I plan on tackling in the near future.
from rb-zlib.
When adding entries from memory you must specify the entire path, not just the file name. In addition, each parent directory in the path needs its own entry:
e.g.
Dim filedata As String = "Hello, world!"
Dim filestream As New BinaryStream(filedata) ' BinaryStream implements Readable
Dim writer As New PKZip.ZipWriter
writer.AppendEntry("word/", Nil, 0)
writer.AppendEntry("word/_rels/", Nil, 0)
writer.AppendEntry("word/_rels/document.xml.rels", filestream, filestream.Length)
writer.Commit(SpecialFolder.Desktop.Child("test.zip"))
The ZipWriter.AppendDirectory method will add directory entries automatically when zipping FolderItems; typing out the example above makes me think it's silly to require each parent to be individually appended when using memory. So I just pushed this change that lets you do this:
Dim filedata As String = "Hello, world!"
Dim filestream As New BinaryStream(filedata) ' BinaryStream implements Readable
Dim writer As New PKZip.ZipWriter
writer.AppendEntry("word/_rels/document.xml.rels", filestream, filestream.Length)
writer.Commit(SpecialFolder.Desktop.Child("test.zip"))
from rb-zlib.
Thanks for your reply. Pretty nice and easy to understand. I dropped the Module into my project. I uses the latest Xojo 2018 Release 3 and my app compiles in 64-Bit. I'll get only one Compiler Error (32-Bit Mode works without errors):
lib.TapeArchive.GetCheckSum, line 7 - Type mismatch error. Expected UInt32, but got Int64
chksum = chksum + UInt32(32 * 8) ' 8 spaces
How can I fix it, to make your nice library also work in 64-Bit Apps?
You'll need also to update all FolderItem.AbsolutePath to FolderItem.NativePath, because AbsolutePath is deprecated. The Deflater returns an error when trying to zip a Folder/File in 64-Bit Mode.
from rb-zlib.
OK, i have troubles with my planned In-Memory Zip Container. I will write the following structure into a Zip-File using AppendEntry. It works fine for single files, but not with folders inside.
Root
- [Content_Types].xml
- _rels
- .rels
- docProps
- app.xml
- core.xml
- word
- _rels
- document.xml.rels
- theme
- theme1.xml
- document.xml
- fontTable.xml
- settings.xml
- styles.xml
- webSettings.xml
- _rels
from rb-zlib.
Related Issues (12)
- ZStream doesn't work HOT 2
- How to read ZIP Content in Memory without extracting to HDD? HOT 3
- zlib in 64 bit Xojo application HOT 8
- ZipWriter and TarWriter open too many files at once HOT 1
- IOException with alias HOT 3
- .docx files generated by ZipWriter don't work in WordPad HOT 4
- How to read the content of an entry as a String in memory without extracting the Zip file? HOT 4
- GZStream should support in-memory compression/decompression HOT 1
- TapeArchive produces malformed tar files HOT 2
- WriteZip creates malformed zip archives HOT 1
- ZStream.Sync and Inflater.SyncToNextFlush are unreliable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rb-zlib.