Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/acorn/riscos.c  view on Meta::CPAN

/*
  Copyright (c) 1990-2002 Info-ZIP.  All rights reserved.

  See the accompanying file LICENSE, version 2000-Apr-09 or later
  (the contents of which are also included in unzip.h) for terms of use.
  If, for some reason, all these files are missing, the Info-ZIP license
  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* riscos.c */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* #define NO_UNZIPH_STUFF */
#define UNZIP_INTERNAL
#include "unzip.h"
#include "riscos.h"

#define MAXEXT 16

char *exts2swap = NULL; /* Extensions to swap (actually, directory names) */

int stat(char *filename,struct stat *res)
{
 int attr;              /* object attributes */
 unsigned int load;     /* load address */
 unsigned int exec;     /* exec address */
 int type;              /* type: 0 not found, 1 file, 2 dir, 3 image */

 if (!res)
   return -1;

 if (SWI_OS_File_5(filename,&type,&load,&exec,(int *)&res->st_size,&attr)!=NULL)
   return -1;

 if (type==0)
   return -1;

 res->st_dev=0;
 res->st_ino=0;
 res->st_nlink=0;
 res->st_uid=1;
 res->st_gid=1;
 res->st_rdev=0;
 res->st_blksize=1024;

 res->st_mode = ((attr & 0001) << 8) | ((attr & 0002) << 6) |
                ((attr & 0020) >> 2) | ((attr & 0040) >> 4);

 switch (type) {
   case 1:                        /* File */
    res->st_mode |= S_IFREG;
    break;
   case 2:                        /* Directory */
    res->st_mode |= S_IFDIR | 0700;
    break;
   case 3:                        /* Image file */
    if (uO.scanimage)
      res->st_mode |= S_IFDIR | 0700;
    else
      res->st_mode |= S_IFREG;
    break;
 }

 if ((((unsigned int) load) >> 20) == 0xfff) {     /* date stamped file */
   register unsigned int t1, t2, tc;

   t1 = (unsigned int) (exec);
   t2 = (unsigned int) (load & 0xff);

   tc = 0x6e996a00U;
   if (t1 < tc)
     t2--;
   t1 -= tc;
   t2 -= 0x33;          /* 00:00:00 Jan. 1 1970 = 0x336e996a00 */

   t1 = (t1 / 100) + (t2 * 42949673U);  /* 0x100000000 / 100 = 42949672.96 */
   t1 -= (t2 / 25);             /* compensate for .04 error */

   res->st_atime = res->st_mtime = res->st_ctime = t1;
 }
 else
   res->st_atime = res->st_mtime = res->st_ctime = 0;



( run in 2.611 seconds using v1.01-cache-2.11-cpan-364913b4093 )