symbian-qemu-0.9.1-12/python-2.6.1/RISCOS/unixstuff.c
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 /* Fudge unix isatty and fileno for RISCOS */
       
     2 
       
     3 #include "unixstuff.h"
       
     4 #include <math.h>
       
     5 #include <time.h>
       
     6 #include "oslib/osfile.h"
       
     7 
       
     8 int fileno(FILE *f)
       
     9 { return (int)f;
       
    10 }
       
    11 
       
    12 int isatty(int fn)
       
    13 { return (fn==fileno(stdin));
       
    14 }
       
    15 
       
    16 bits unixtime(bits ld,bits ex)
       
    17 { ld&=0xFF;
       
    18   ld-=51;
       
    19   if(ex<1855547904U) ld--;
       
    20   ex-=1855548004U;
       
    21   return ex/100+42949673U*ld-ld/25;
       
    22 }
       
    23 
       
    24 
       
    25 /* from RISC OS infozip, preserves filetype in ld */
       
    26 int acorntime(bits *ex, bits *ld, time_t utime)
       
    27 {
       
    28    unsigned timlo;      /* 3 lower bytes of acorn file-time plus carry byte */
       
    29    unsigned timhi;      /* 2 high bytes of acorn file-time */
       
    30 
       
    31    timlo = ((unsigned)utime & 0x00ffffffU) * 100 + 0x00996a00U;
       
    32    timhi = ((unsigned)utime >> 24);
       
    33    timhi = timhi * 100 + 0x0000336eU + (timlo >> 24);
       
    34    if (timhi & 0xffff0000U)
       
    35        return 1;        /* calculation overflow, do not change time */
       
    36 
       
    37    /* insert the five time bytes into loadaddr and execaddr variables */
       
    38    *ex = (timlo & 0x00ffffffU) | ((timhi & 0x000000ffU) << 24);
       
    39    *ld = (*ld & 0xffffff00U)   | ((timhi >> 8) & 0x000000ffU);
       
    40 
       
    41    return 0;            /* subject to future extension to signal overflow */
       
    42 }
       
    43 
       
    44 
       
    45 int isdir(char *fn)
       
    46 { int ob;
       
    47   if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0;
       
    48   switch (ob)
       
    49   {   case osfile_IS_DIR:return 1;
       
    50     case osfile_IS_IMAGE:return 1;
       
    51   }
       
    52   return 0;
       
    53 }
       
    54 
       
    55 int isfile(char *fn)
       
    56 { int ob;
       
    57   if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0;
       
    58   switch (ob)
       
    59   {  case osfile_IS_FILE:return 1;
       
    60     case osfile_IS_IMAGE:return 1;
       
    61   }
       
    62   return 0;
       
    63 }
       
    64 
       
    65 int object_exists(char *fn)
       
    66 { int ob;
       
    67   if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0;
       
    68   switch (ob)
       
    69   {  case osfile_IS_FILE:return 1;
       
    70       case osfile_IS_DIR:return 1;
       
    71     case osfile_IS_IMAGE:return 1;
       
    72   }
       
    73   return 0;
       
    74 }