3 * Operating System specific function (Acorn)
5 * $Header: acorn.c 1.1 93/03/05 $
7 * Revision 1.1 93/03/05 14:34:04 arb
18 * return the length of a file
21 filesize(char *pathname
)
24 _kernel_osfile_block osblock
;
26 rc
= _kernel_osfile(17, pathname
, &osblock
);
27 if (rc
== _kernel_ERROR
)
29 /* Bit 1 is set if a file, bit 2 if a directory, both if image file */
31 return ((Word
) osblock
.start
);
37 * test for the existance of a file or directory
43 _kernel_osfile_block osblock
;
45 rc
= _kernel_osfile(17, pathname
, &osblock
);
46 if (rc
== _kernel_ERROR
)
47 return (NOEXIST
); /* assumes error was because file
48 doesn't exist... could be wrong! */
50 return (ISFILE
); /* might not be a regular file... (eg. image) */
61 makedir(char *pathname
)
64 _kernel_osfile_block osblock
;
66 osblock
.start
= 0; /* Default number of entries */
67 rc
= _kernel_osfile(8, pathname
, &osblock
);
68 if (rc
== _kernel_ERROR
)
69 return (-1); /* Should set errno */
75 * stamp a file with date and time
78 filestamp(Header
*header
, char *filename
)
81 _kernel_osfile_block osblock
;
83 if ((header
->load
& (Word
) 0xfff00000) != (Word
) 0xfff00000)
84 return (0); /* not a timestamp */
86 osblock
.load
= header
->load
;
87 osblock
.exec
= header
->exec
;
88 osblock
.end
= header
->attr
;
89 rc
= _kernel_osfile(1, filename
, &osblock
);
90 if (rc
== _kernel_ERROR
)
97 * read byte from stream (only one line from stdin supported)
100 read(int fd
, void *buffer
, int len
)
102 _kernel_swi_regs regs
;
105 if (fd
!= 0) /* Only stdin, sorry! */
107 regs
.r
[0] = (int) buffer
;
109 regs
.r
[2] = 1; /* Low/high values to store */
111 if (_kernel_swi_c(OS_ReadLine
, ®s
, ®s
, &carry
))
112 return (-1); /* Error occurred */
114 return (-1); /* Escape pressed */
115 return (regs
.r
[1]); /* Return number of bytes read */