3 * Operating System specific function (DOS)
5 * $Header: msdos.c 1.0 95/07/21 $
7 * Revision 1.0 95/07/21 xx:xx:xx BB
8 * Initial revision, based on winnt.c.
22 #include <string.h> /* for memset */
26 * return the length of a file
29 filesize(char *pathname
)
33 if (stat(pathname
, &statb
) < 0)
36 return (Word
) statb
.st_size
;;
40 * test for the existance of a file or directory
47 if (stat(pathname
, &statb
) < 0)
50 if (statb
.st_mode
& S_IFDIR
)
60 makedir(char *pathname
)
62 return mkdir(pathname
);
66 * stamp a file with date and time
69 filestamp(Header
*header
, char *filename
)
73 struct utimbuf utimbuf
;
76 /* BB: DOS utime() cannot stamp directories.
77 It could be done by directly editing the directory entries
78 (simulate a disc editor) but since e.g. pkunzip does not
79 stamp extracted directories either, I did not bother and
80 kept the next line from winnt.c.
81 ``It is left as an exercice to the interested reader.''
82 NB: Do not forget to stamp the . entry in the directory
84 if (exist(filename
) == ISDIR
)
87 if ((header
->load
& (Word
) 0xfff00000UL
) != (Word
) 0xfff00000UL
)
88 return (0); /* not a timestamp */
90 memset((char *) &tm
, '\0', sizeof(tm
));
92 /* Borland C/C++ 4 is `a bit fuzzy' about the next line 8-( */
93 /* if (!(date = makedate(header))) */
94 if ((date
= makedate(header
)) == 0)
97 tm
.tm_sec
= date
->second
;
98 tm
.tm_min
= date
->minute
;
99 tm
.tm_hour
= date
->hour
;
100 tm
.tm_mday
= date
->day
;
101 tm
.tm_mon
= date
->month
- 1;
102 tm
.tm_year
= date
->year
;
103 filetime
= mktime(&tm
);
105 utimbuf
.actime
= filetime
;
106 utimbuf
.modtime
= filetime
;
107 return (utime(filename
, &utimbuf
));