VirtualBox

Changeset 51696 in vbox


Ignore:
Timestamp:
Jun 23, 2014 4:30:29 PM (10 years ago)
Author:
vboxsync
Message:

Runtime: PKZip stream reader

Location:
trunk
Files:
2 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/err.h

    r50956 r51696  
    17121712/** @} */
    17131713
     1714/** @name Pkzip status codes
     1715 * @{ */
     1716/** No end of central directory record found. */
     1717#define VERR_PKZIP_NO_EOCB                      (-960)
     1718/** Too long name string. */
     1719#define VERR_PKZIP_NAME_TOO_LONG                (-961)
     1720/** Local file header corrupt. */
     1721#define VERR_PKZIP_BAD_LF_HEADER                (-962)
     1722/** Central directory file header corrupt. */
     1723#define VERR_PKZIP_BAD_CDF_HEADER               (-963)
     1724/** Encountered an unknown type flag. */
     1725#define VERR_PKZIP_UNKNOWN_TYPE_FLAG            (-964)
     1726/** Found a ZIP64 Extra Information Field in a ZIP32 file. */
     1727#define VERR_PKZIP_ZIP64EX_IN_ZIP32             (-965)
     1728
     1729
    17141730/** @name RTZip status codes
    17151731 * @{ */
  • trunk/include/iprt/mangling.h

    r51087 r51696  
    19031903# define RTZipGzipDecompressIoStream                    RT_MANGLER(RTZipGzipDecompressIoStream)
    19041904# define RTZipTarCmd                                    RT_MANGLER(RTZipTarCmd)
     1905# define RTZipUnzipCmd                                  RT_MANGLER(RTZipUnzipCmd)
    19051906# define RTZipTarFsStreamFromIoStream                   RT_MANGLER(RTZipTarFsStreamFromIoStream)
    19061907# define RTZipXarFsStreamFromIoStream                   RT_MANGLER(RTZipXarFsStreamFromIoStream)
     1908# define RTZipPkzipFsStreamFromIoStream                 RT_MANGLER(RTZipPkzipFsStreamFromIoStream)
    19071909/*
    19081910 * Stable variables (alphabetical order):
  • trunk/include/iprt/zip.h

    r48836 r51696  
    8686    /** Lempel-Ziv-Oberhumer compression. */
    8787    RTZIPTYPE_LZO,
     88    /* Zlib compression the data without zlib header. */
     89    RTZIPTYPE_ZLIB_NO_HEADER,
    8890    /** End of valid the valid compression types.  */
    8991    RTZIPTYPE_END
     
    217219
    218220/**
     221 * Opens a zip decompression I/O stream.
     222 *
     223 * @returns IPRT status code.
     224 *
     225 * @param   hVfsIosIn           The compressed input stream (must be readable).
     226 *                              The reference is not consumed, instead another
     227 *                              one is retained.
     228 * @param   fFlags              Flags, MBZ.
     229 * @param   phVfsIosUnzip       Where to return the handle to the gunzipped I/O
     230 *                              stream (read).
     231 */
     232RTDECL(int) RTZipDecompressIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSIOSTREAM phVfsIosUnzip);
     233
     234
     235/**
    219236 * Opens a gzip decompression I/O stream.
    220237 *
     
    279296
    280297/**
    281  * Opens a XAR filesystem stream.
    282  *
    283  * This is used to extract, list or check a XAR archive.
     298 * Opens a ZIP filesystem stream.
     299 *
     300 * This is used to extract, list or check a ZIP archive.
    284301 *
    285302 * @returns IPRT status code.
     
    288305 *                              not consumed, instead another one is retained.
    289306 * @param   fFlags              Flags, MBZ.
     307 * @param   phVfsFss            Where to return the handle to the TAR
     308 *                              filesystem stream.
     309 */
     310RTDECL(int) RTZipPkzipFsStreamFromIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSFSSTREAM phVfsFss);
     311
     312/**
     313 * A mini UNZIP program.
     314 *
     315 * @returns Program exit code.
     316 * @
     317 * @param   cArgs               The number of arguments.
     318 * @param   papszArgs           The argument vector.  (Note that this may be
     319 *                              reordered, so the memory must be writable.)
     320 */
     321RTDECL(RTEXITCODE) RTZipUnzipCmd(unsigned cArgs, char **papszArgs);
     322
     323/**
     324 * Opens a XAR filesystem stream.
     325 *
     326 * This is used to extract, list or check a XAR archive.
     327 *
     328 * @returns IPRT status code.
     329 *
     330 * @param   hVfsIosIn           The compressed input stream.  The reference is
     331 *                              not consumed, instead another one is retained.
     332 * @param   fFlags              Flags, MBZ.
    290333 * @param   phVfsFss            Where to return the handle to the XAR filesystem
    291334 *                              stream.
  • trunk/src/VBox/Runtime/Makefile.kmk

    r51346 r51696  
    464464        common/zip/tar.cpp \
    465465        common/zip/tarcmd.cpp \
     466        common/zip/unzipcmd.cpp \
    466467        common/zip/tarvfs.cpp \
    467468        common/zip/gzipvfs.cpp \
     469        common/zip/pkzipvfs.cpp \
    468470        common/zip/zip.cpp \
    469471        generic/createtemp-generic.cpp \
  • trunk/src/VBox/Runtime/common/zip/zip.cpp

    r49233 r51696  
    420420
    421421#ifdef RTZIP_USE_ZLIB
     422
     423/*
     424 * Missing definitions from zutil.h. We need these constants for calling
     425 * inflateInit2() / deflateInit2().
     426 */
     427# ifndef Z_DEF_WBITS
     428#  define Z_DEF_WBITS        MAX_WBITS
     429# endif
     430# ifndef Z_DEF_MEM_LEVEL
     431#  define Z_DEF_MEM_LEVEL    8
     432# endif
     433
    422434/**
    423435 * Convert from zlib errno to iprt status code.
     
    543555 * @param   pZip        The compressor instance.
    544556 * @param   enmLevel    The desired compression level.
    545  */
    546 static DECLCALLBACK(int) rtZipZlibCompInit(PRTZIPCOMP pZip, RTZIPLEVEL enmLevel)
     557 * @param   fZlibHeader If true, write the Zlib header.
     558 */
     559static DECLCALLBACK(int) rtZipZlibCompInit(PRTZIPCOMP pZip, RTZIPLEVEL enmLevel, bool fZlibHeader)
    547560{
    548561    pZip->pfnCompress = rtZipZlibCompress;
     
    564577    pZip->u.Zlib.opaque    = pZip;
    565578
    566     int rc = deflateInit(&pZip->u.Zlib, iLevel);
     579    int rc = deflateInit2(&pZip->u.Zlib, iLevel, Z_DEFLATED, fZlibHeader ? Z_DEF_WBITS : -Z_DEF_WBITS,
     580                          Z_DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
    567581    return rc >= 0 ? rc = VINF_SUCCESS : zipErrConvertFromZlib(rc, true /*fCompressing*/);
    568582}
     
    636650 * @returns iprt status code.
    637651 * @param   pZip        The decompressor instance.
    638  */
    639 static DECLCALLBACK(int) rtZipZlibDecompInit(PRTZIPDECOMP pZip)
     652 * @param   fZlibHeader If true, expect the Zlib header.
     653 */
     654static DECLCALLBACK(int) rtZipZlibDecompInit(PRTZIPDECOMP pZip, bool fZlibHeader)
    640655{
    641656    pZip->pfnDecompress = rtZipZlibDecompress;
     
    645660    pZip->u.Zlib.opaque    = pZip;
    646661
    647     int rc = inflateInit(&pZip->u.Zlib);
     662    int rc = inflateInit2(&pZip->u.Zlib, fZlibHeader ? Z_DEF_WBITS : -Z_DEF_WBITS);
    648663    return rc >= 0 ? VINF_SUCCESS : zipErrConvertFromZlib(rc, false /*fCompressing*/);
    649664}
     
    14061421
    14071422        case RTZIPTYPE_ZLIB:
     1423        case RTZIPTYPE_ZLIB_NO_HEADER:
    14081424#ifdef RTZIP_USE_ZLIB
    1409             rc = rtZipZlibCompInit(pZip, enmLevel);
     1425            rc = rtZipZlibCompInit(pZip, enmLevel, enmType == RTZIPTYPE_ZLIB /*fZlibHeader*/);
    14101426#endif
    14111427            break;
     
    15841600
    15851601        case RTZIPTYPE_ZLIB:
     1602        case RTZIPTYPE_ZLIB_NO_HEADER:
    15861603#ifdef RTZIP_USE_ZLIB
    1587             rc = rtZipZlibDecompInit(pZip);
     1604            rc = rtZipZlibDecompInit(pZip, pZip->enmType == RTZIPTYPE_ZLIB /*fHeader*/);
    15881605#else
    15891606            AssertMsgFailed(("Zlib is not include in this build!\n"));
  • trunk/src/VBox/Runtime/tools/Makefile.kmk

    r49116 r51696  
    6666 RTTar_SOURCES = RTTar.cpp
    6767
     68 # RTUnzip - our unzip clone (for testing the unzip streaming code)
     69 PROGRAMS += RTUnzip
     70 RTUnzip_TEMPLATE = VBoxR3Tool
     71 RTUnzip_SOURCES = RTUnzip.cpp
     72
    6873 # RTNtDbgHelp - our tar clone (for testing the tar/gzip/gunzip streaming code)
    6974 PROGRAMS.win += RTNtDbgHelp
  • trunk/src/VBox/Runtime/tools/RTUnzip.cpp

    r51634 r51696  
    4040    if (RT_FAILURE(rc))
    4141        return RTMsgInitFailure(rc);
    42     return RTZipTarCmd(argc, argv);
     42    return RTZipUnzipCmd(argc, argv);
    4343}
    4444
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette