Git Product home page Git Product logo

Comments (5)

charonn0 avatar charonn0 commented on July 23, 2024 1

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.

charonn0 avatar charonn0 commented on July 23, 2024 1

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.

charonn0 avatar charonn0 commented on July 23, 2024 1

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.

XojoGermany avatar XojoGermany commented on July 23, 2024

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.

XojoGermany avatar XojoGermany commented on July 23, 2024

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

from rb-zlib.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.