Coder Social home page Coder Social logo

is big-endian compatible ? about junzip HOT 5 OPEN

denisdemaisbr avatar denisdemaisbr commented on July 24, 2024
is big-endian compatible ?

from junzip.

Comments (5)

jokkebk avatar jokkebk commented on July 24, 2024

I haven't tested them on those. It depends how file reading operations and such arrange uint32_t and similar multibyte variables. One would need to run the code and see if the signature check against 0x02014B50 in the code works, and if file offsets, sizes etc. work correctly. Unfortunately I don't have access to big-endian systems at the moment.

from junzip.

denisdemaisbr avatar denisdemaisbr commented on July 24, 2024

some properties of file header need converstion on big-endian systems.
i will try test and report you

system: arm32 big endian

from junzip.

PerBothner avatar PerBothner commented on July 24, 2024

A possible solution is to use <endian.h>. For example in jzReadLocalFileHeader instead of:

memcpy(header, &localHeader.compressionMethod, sizeof(JZFileHeader));

write:

header->compressionMethod = le16toh(localHeader.compressionMethod);
header->lastModFileTime = le16toh(localHeader.lastModFileTime);

and so on. Of course this conversion must be done before any of the values are actually used.

A disadvantage is that <endian.h> isn't very portable - but the existing code isn't very portable anyway, as it requires __attribute__ ((__packed__)). The macros in <endian.h> should be pretty efficient.

from junzip.

PerBothner avatar PerBothner commented on July 24, 2024

For DomTerm I started with JUnzip, but re-wrote it pretty extensively. It should now be more portable, and I expect no byte-order problems. It is also simpler and faster, by using a simplifying assuming that the entire zip file is mmap'd into memory. See files lws-term/junzip.h and lws-term/junzip.c in the GitHub source code.

from junzip.

jokkebk avatar jokkebk commented on July 24, 2024

@PerBothner very nice. :) I would suggest contributing changes back to JUnzip, but this is in no way an active project for me at the moment, so I'll leave this issue "open" for others to see. For same reason, I think endianness remains somewhat x86 centric for the time being, unless someone submits a pull request I can make sense of. 😄

from junzip.

Related Issues (4)

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.