summaryrefslogtreecommitdiff
path: root/RISCOS/unixstuff.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-10-24 20:13:15 +0000
committerGuido van Rossum <guido@python.org>2001-10-24 20:13:15 +0000
commitcd03c3a2e6a3f2b7dc4b5bcaf23f56fc0e7cd52e (patch)
treeb794ed75367867b432f3c5361e722b7f8631fca0 /RISCOS/unixstuff.c
parent3cc281bbacd50f12623bda455db966079afe0972 (diff)
downloadcpython-cd03c3a2e6a3f2b7dc4b5bcaf23f56fc0e7cd52e.tar.gz
SF patch #474590 -- RISC OS support
Diffstat (limited to 'RISCOS/unixstuff.c')
-rw-r--r--RISCOS/unixstuff.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/RISCOS/unixstuff.c b/RISCOS/unixstuff.c
index 10648d264f..83e6212c82 100644
--- a/RISCOS/unixstuff.c
+++ b/RISCOS/unixstuff.c
@@ -1,8 +1,9 @@
/* Fudge unix isatty and fileno for RISCOS */
-#include "h.unixstuff"
+#include "unixstuff.h"
#include <math.h>
-#include "h.osfile"
+#include <time.h>
+#include "oslib/osfile.h"
int fileno(FILE *f)
{ return (int)f;
@@ -15,48 +16,59 @@ int isatty(int fn)
bits unixtime(bits ld,bits ex)
{ ld&=0xFF;
ld-=51;
- if(ex<1855548004U) ld--;
+ if(ex<1855547904U) ld--;
ex-=1855548004U;
- return ex/100+42949672*ld+(95*ld)/100;
+ return ex/100+42949673U*ld-ld/25;
}
-int unlink(char *fname)
-{ remove(fname);
- return 0;
-}
+/* from RISC OS infozip, preserves filetype in ld */
+int acorntime(bits *ex, bits *ld, time_t utime)
+{
+ unsigned timlo; /* 3 lower bytes of acorn file-time plus carry byte */
+ unsigned timhi; /* 2 high bytes of acorn file-time */
+
+ timlo = ((unsigned)utime & 0x00ffffffU) * 100 + 0x00996a00U;
+ timhi = ((unsigned)utime >> 24);
+ timhi = timhi * 100 + 0x0000336eU + (timlo >> 24);
+ if (timhi & 0xffff0000U)
+ return 1; /* calculation overflow, do not change time */
+
+ /* insert the five time bytes into loadaddr and execaddr variables */
+ *ex = (timlo & 0x00ffffffU) | ((timhi & 0x000000ffU) << 24);
+ *ld = (*ld & 0xffffff00U) | ((timhi >> 8) & 0x000000ffU);
+
+ return 0; /* subject to future extension to signal overflow */
+}
-/*#define RET(k) {printf(" %d\n",k);return k;}*/
-#define RET(k) return k
int isdir(char *fn)
{ int ob;
-/* printf("isdir %s",fn);*/
- if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
+ if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0;
switch (ob)
- { case osfile_IS_DIR:RET(1);
- case osfile_IS_IMAGE:RET(1);
+ { case osfile_IS_DIR:return 1;
+ case osfile_IS_IMAGE:return 1;
}
- RET(0);
+ return 0;
}
int isfile(char *fn)
-{ int ob; /*printf("isfile %s",fn);*/
- if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
+{ int ob;
+ if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0;
switch (ob)
- { case osfile_IS_FILE:RET(1);
- case osfile_IS_IMAGE:RET(1);
+ { case osfile_IS_FILE:return 1;
+ case osfile_IS_IMAGE:return 1;
}
- RET(0);
+ return 0;
}
-int exists(char *fn)
-{ int ob; /*printf("exists %s",fn);*/
- if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
+int object_exists(char *fn)
+{ int ob;
+ if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0;
switch (ob)
- { case osfile_IS_FILE:RET(1);
- case osfile_IS_DIR:RET(1);
- case osfile_IS_IMAGE:RET(1);
+ { case osfile_IS_FILE:return 1;
+ case osfile_IS_DIR:return 1;
+ case osfile_IS_IMAGE:return 1;
}
- RET(0);
+ return 0;
}