Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/beos/beos.c  view on Meta::CPAN

    ulg  full_size = 0;
    uch  flags     = 0;
    uch *attrbuff  = NULL;
    int retval;

    if( extra_field == NULL ) {
        return;
    }

    /* Collect the data from the extra field buffer. */
    id        = makeword(ptr);    ptr += 2;   /* we don't use this... */
    size      = makeword(ptr);    ptr += 2;
    full_size = makelong(ptr);    ptr += 4;
    flags     = *ptr;             ptr++;

    /* Do a little sanity checking. */
    if (flags & EB_BE_FL_BADBITS) {
        /* corrupted or unsupported */
        Info(slide, 0x201, ((char *)slide,
          "Unsupported flags set for this BeOS extra field, skipping.\n"));
        return;
    }
    if (size <= EB_BEOS_HLEN) {
        /* corrupted, unsupported, or truncated */
        Info(slide, 0x201, ((char *)slide,
             "BeOS extra field is %d bytes, should be at least %d.\n", size,
             EB_BEOS_HLEN));
        return;
    }
    if (full_size < (size - EB_BEOS_HLEN)) {
        /* possible old archive? will this screw up on valid archives? */
        Info(slide, 0x201, ((char *)slide,
             "Skipping attributes: BeOS extra field is %d bytes, "
             "data size is %ld.\n", size - EB_BEOS_HLEN, full_size));
        return;
    }

    /* Find the BeOS file attribute data. */
    if (flags & EB_BE_FL_UNCMPR) {
        /* Uncompressed data */
        attrbuff = ptr;
    } else {
        /* Compressed data */
        attrbuff = (uch *)malloc( full_size );
        if (attrbuff == NULL) {
            /* No memory to uncompress attributes */
            Info(slide, 0x201, ((char *)slide,
                 "Can't allocate memory to uncompress file attributes.\n"));
            return;
        }

        retval = memextract(__G__ attrbuff, full_size,
                            ptr, size - EB_BEOS_HLEN);
        if( retval != PK_OK ) {
            /* error uncompressing attributes */
            Info(slide, 0x201, ((char *)slide,
                 "Error uncompressing file attributes.\n"));

            /* Some errors here might not be so bad; we should expect */
            /* some truncated data, for example.  If the data was     */
            /* corrupt, we should _not_ attempt to restore the attrs  */
            /* for this file... there's no way to detect what attrs   */
            /* are good and which are bad.                            */
            free (attrbuff);
            return;
        }
    }

    /* Now attempt to set the file attributes on the extracted file. */
    retval = set_file_attrs(path, attrbuff, (off_t)full_size);
    if (retval != EOK) {
        Info(slide, 0x201, ((char *)slide,
             "Error writing file attributes.\n"));
    }

    /* Clean up, if necessary */
    if (attrbuff != ptr) {
        free(attrbuff);
    }

    return;
}

#ifdef BEOS_USE_PRINTEXFIELD
static void printBeOSexfield( int isdir, uch *extra_field )
{
    uch *ptr       = extra_field;
    ush  id        = 0;
    ush  size      = 0;
    ulg  full_size = 0;
    uch  flags     = 0;

    /* Tell picky compilers to be quiet. */
    isdir = isdir;

    if( extra_field == NULL ) {
        return;
    }

    /* Collect the data from the buffer. */
    id        = makeword( ptr );    ptr += 2;
    size      = makeword( ptr );    ptr += 2;
    full_size = makelong( ptr );    ptr += 4;
    flags     = *ptr;               ptr++;

    if( id != EF_BEOS ) {
        /* not a 'Be' field */
        printf("\t*** Unknown field type (0x%04x, '%c%c')\n", id,
               (char)(id >> 8), (char)id);
    }

    if( flags & EB_BE_FL_BADBITS ) {
        /* corrupted or unsupported */
        printf("\t*** Corrupted BeOS extra field:\n");
        printf("\t*** unknown bits set in the flags\n");
        printf("\t*** (Possibly created by an old version of zip for BeOS.\n");
    }

    if( size <= EB_BEOS_HLEN ) {
        /* corrupted, unsupported, or truncated */
        printf("\t*** Corrupted BeOS extra field:\n");



( run in 1.808 second using v1.01-cache-2.11-cpan-6aa56a78535 )