Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/macos/source/macos.c  view on Meta::CPAN

            }

#ifdef DEBUG_TIME
            {
            struct tm *tp = gmtime(&z_utime.ctime);
            printf(
              "SetFileTime:  Unix e.f. creat. time = %d/%2d/%2d  %2d:%2d:%2d -> %lu UTC\n",
              tp->tm_year, tp->tm_mon+1, tp->tm_mday,
              tp->tm_hour, tp->tm_min, tp->tm_sec, z_utime.ctime);
            tp = gmtime(&z_utime.mtime);
            printf(
              "SetFileTime:  Unix e.f. modif. time = %d/%2d/%2d  %2d:%2d:%2d -> %lu UTC\n",
              tp->tm_year, tp->tm_mon+1, tp->tm_mday,
              tp->tm_hour, tp->tm_min, tp->tm_sec, z_utime.mtime);
            }
#endif /* DEBUG_TIME */


        else /* no Unix time field found - use dostime  */
#endif /* !USE_EF_UT_TIME */
            {
            TTrace((stderr, "SetFileTime:  using DOS-Datetime ! \n",
                    z_utime.mtime));
            fpb.hFileInfo.ioFlMdDat = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
            UNIX_TO_MACOS(fpb.hFileInfo.ioFlMdDat);
            fpb.hFileInfo.ioFlCrDat = fpb.hFileInfo.ioFlMdDat;
            }

     /* Restore ioDirID field in pb which was changed by PBGetCatInfoSync */
        fpb.hFileInfo.ioDirID = CurrentFile.parID;

        if (err == noErr)
            {
            err = PBSetCatInfoSync((CInfoPBPtr)&fpb);
            printerr("PBSetCatInfoSync",err,err,__LINE__,__FILE__,G.filename);
            }
        if (err != noErr)
            Info(slide, 0x201, ((char *)slide, LoadFarString(ErrNoTimeSet),
              FnFilter1(G.filename)));
    }

return err;
} /* end function SetFileTime() */




#ifndef SFX

/************************/
/*  Function version()  */
/************************/

void version(__G)
    __GDEF
{
/*
ZCONST char Far CompiledWith[] =
               "Compiled with %s%s for %s%s%s%s.\n\n"; */

char DateTime[50];

#ifdef __MWERKS__
char CompVer[10];
sprintf(CompVer, "%x", __MWERKS__);
#endif

    sprintf(DateTime,"%s  %s",__DATE__, __TIME__);

    sprintf((char *)slide, LoadFarString(CompiledWith),

#ifdef __MWERKS__

      " Metrowerks CodeWarrior version ",CompVer,
#else
      " ", " ",
#endif

#ifdef __MC68K__
      " MC68K Processor",
#else
      " PowerPC Processor",
#endif

#ifdef __DATE__

      "\n compile time: ", DateTime, ""
#else
      "", "", ""
#endif
    );

    (*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);

} /* end function version() */

#endif /* !SFX */





/***********************/
/* Function macmkdir() */
/***********************/

int macmkdir(char *path)
{
    OSErr err = -1;
    OSErr err_rc;
    char CompletePath[NAME_MAX], CompletePath2[NAME_MAX];
    Boolean isDirectory = false;
    short CurrentFork;
    unsigned pathlen;
    long dirID;

    AssertStr(path, path)

    GetExtraFieldData(&MacZipMode, &newExtraField);

    if (MacZipMode >= JohnnyLee_EF) {
        RfDfFilen2Real(CompletePath, G.filename, MacZipMode,
                       (newExtraField.flags & EB_M3_FL_NOCHANGE), &CurrentFork);
        if (CurrentFork == ResourceFork)
            /* don't build a 'XtraStuf.mac:' dir  */
            return 0;
    }

    if (!IgnoreEF_Macfilename)
        {
        pathlen = strlen(path);
        strcpy(CompletePath, uO.exdir);
        strcat(CompletePath, newExtraField.FullPath);
        CompletePath[pathlen] = 0x00;
        }
    else
        {
        strcpy(CompletePath, path);
        }

    GetCompletePath(CompletePath2, CompletePath, &CurrentFile, &err);
    printerr("GetCompletePath", (err != -43) && (err != -120) && (err != 0),
              err, __LINE__, __FILE__, CompletePath2);


    err = FSpGetDirectoryID(&CurrentFile, &dirID, &isDirectory);
    printerr("macmkdir FSpGetDirectoryID ", (err != -43) && (err != 0),

unzip-6.0/macos/source/macos.c  view on Meta::CPAN

            }

        case EF_JLMAC:
            {           /* Johnny Lee's old maczip format */
            *MacZipMode = JohnnyLee_EF;
            IgnoreEF_Macfilename = true;
            return true;
            }

        default:
            {           /* any other format */
            *MacZipMode = UnKnown_EF;
            IgnoreEF_Macfilename = true;
            return false;
            }
        }

    return false;
}




/*
** Return a unsigned long from a four-byte sequence
** in big endian format
*/

ulg makePPClong(ZCONST uch *sig)
{
    return (((ulg)sig[0]) << 24)
         + (((ulg)sig[1]) << 16)
         + (((ulg)sig[2]) << 8)
         +  ((ulg)sig[3]);
}




/*
** Return a unsigned short from a two-byte sequence
** in big endian format
*/

ush makePPCword(ZCONST uch *b)
{
    return (ush)((b[0] << 8) | b[1]);
}




/*
** Print mac extra-field
**
*/

static void PrintMacExtraInfo(MACINFO *mi)
{
#define MY_FNDRINFO fpb.hFileInfo.ioFlFndrInfo
    DateTimeRec  MacTime;
    static ZCONST char space[] = "                                    ";
    static ZCONST char line[]  = "------------------------------------"\
                                 "------------------------------";

    printf("\n\n%s", line);

    printf("\nFullPath      = [%s]", mi->FullPath);
    printf("\nFinderComment = [%s]", mi->FinderComment);
    printf("\nText Encoding Base (Filename)       \"%s\" \n",
        PrintTextEncoding(mi->fpb.hFileInfo.ioFlXFndrInfo.fdScript));

    printf("\nExtraField Flags :                  %s  0x%x  %4d",
             sBit2Str(mi->flags), mi->flags, mi->flags);

    printf("\n%sExtra Field is %s", space,
           (mi->flags & EB_M3_FL_UNCMPR ?
            "Uncompressed" : "Compressed"));
    printf("\n%sFile Dates are in %u Bit", space,
           (mi->flags & EB_M3_FL_TIME64 ? 64 : 32));
    printf("\n%sFile UTC time adjustments are %ssupported", space,
           (mi->flags & EB_M3_FL_NOUTC ? "not " : ""));
    printf("\n%sFile Name is %schanged", space,
           (mi->flags & EB_M3_FL_NOCHANGE ? "not " : ""));
    printf("\n%sFile is a %s\n", space,
           (mi->flags & EB_M3_FL_DATFRK ?
            "Datafork" : "Resourcefork"));

    /* not all type / creator codes are printable */
    if (isprint((char)(mi->MY_FNDRINFO.fdType >> 24)) &&
        isprint((char)(mi->MY_FNDRINFO.fdType >> 16)) &&
        isprint((char)(mi->MY_FNDRINFO.fdType >> 8)) &&
        isprint((char)mi->MY_FNDRINFO.fdType))
    {
        printf("\nFile Type =                         [%c%c%c%c]  0x%lx",
            (char)(mi->MY_FNDRINFO.fdType >> 24),
            (char)(mi->MY_FNDRINFO.fdType >> 16),
            (char)(mi->MY_FNDRINFO.fdType >> 8),
            (char)(mi->MY_FNDRINFO.fdType),
            mi->MY_FNDRINFO.fdType);
    }
    else
    {
        printf("\nFile Type =                                     0x%lx",
            mi->MY_FNDRINFO.fdType);
    }

    if (isprint((char)(mi->MY_FNDRINFO.fdCreator >> 24)) &&
        isprint((char)(mi->MY_FNDRINFO.fdCreator >> 16)) &&
        isprint((char)(mi->MY_FNDRINFO.fdCreator >> 8)) &&
        isprint((char)mi->MY_FNDRINFO.fdCreator))
    {
        printf("\nFile Creator =                      [%c%c%c%c]  0x%lx",
            (char)(mi->MY_FNDRINFO.fdCreator >> 24),
            (char)(mi->MY_FNDRINFO.fdCreator >> 16),
            (char)(mi->MY_FNDRINFO.fdCreator >> 8),
            (char)(mi->MY_FNDRINFO.fdCreator),
            mi->MY_FNDRINFO.fdCreator);
    }
    else
    {



( run in 3.326 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )