3 * Operating System specific function (UNIX)
5 * $Header: unix.c 1.6 94/12/13 $
7 * Revision 1.6 94/12/13 11:36:31 arb
8 * Changed use of timelocal() to SunOS 4 only... hope that's right!
10 * Revision 1.5 92/12/07 17:18:49 duplain
13 * Revision 1.4 92/10/19 09:35:10 duplain
14 * Changed use of timelocal() to SunOS only... hope that's right.
16 * Revision 1.3 92/10/06 12:12:51 duplain
17 * Date/time conversion now done by mktime() or timelocal().
19 * Revision 1.2 92/10/01 11:23:10 duplain
22 * Revision 1.1 92/09/29 18:02:28 duplain
27 #include <sys/types.h>
37 * return the length of a file
40 filesize(char *pathname
)
44 if (stat(pathname
, &statb
) < 0)
47 return ((Word
) statb
.st_size
);
51 * test for the existance of a file or directory
58 if (stat(pathname
, &statb
) < 0)
59 return (NOEXIST
); /* assumes error was because file
60 doesn't exist... could be wrong! */
61 if (statb
.st_mode
& S_IFDIR
)
64 return (ISFILE
); /* might not be a regular file... */
71 makedir(char *pathname
)
73 return (mkdir(pathname
, 0777));
77 * stamp a file with date and time
80 filestamp(Header
*header
, char *filename
)
84 struct utimbuf utimbuf
;
87 if ((header
->load
& (Word
) 0xfff00000) != (Word
) 0xfff00000)
88 return (0); /* not a timestamp */
90 memset((char *) &tm
, '\0', sizeof(tm
));
92 if (!(date
= makedate(header
)))
95 tm
.tm_sec
= date
->second
;
96 tm
.tm_min
= date
->minute
;
97 tm
.tm_hour
= date
->hour
;
98 tm
.tm_mday
= date
->day
;
99 tm
.tm_mon
= date
->month
- 1;
100 tm
.tm_year
= date
->year
;
101 filetime
= mktime(&tm
);
103 utimbuf
.actime
= filetime
;
104 utimbuf
.modtime
= filetime
;
105 return (utime(filename
, &utimbuf
));