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.
18 #include <string.h> /* for memset */
22 * return the length of a file
25 filesize(char *pathname
)
29 if (stat(pathname
, &statb
) < 0)
32 return (Word
) statb
.st_size
;;
36 * test for the existance of a file or directory
43 if (stat(pathname
, &statb
) < 0)
46 if (statb
.st_mode
& S_IFDIR
)
56 makedir(char *pathname
)
58 return mkdir(pathname
);
62 * stamp a file with date and time
65 filestamp(Header
*header
, char *filename
)
69 struct utimbuf utimbuf
;
72 /* BB: DOS utime() cannot stamp directories.
73 It could be done by directly editing the directory entries
74 (simulate a disc editor) but since e.g. pkunzip does not
75 stamp extracted directories either, I did not bother and
76 kept the next line from winnt.c.
77 ``It is left as an exercice to the interested reader.''
78 NB: Do not forget to stamp the . entry in the directory
80 if (exist(filename
) == ISDIR
)
83 if ((header
->load
& (Word
) 0xfff00000UL
) != (Word
) 0xfff00000UL
)
84 return (0); /* not a timestamp */
86 memset((char *) &tm
, '\0', sizeof(tm
));
88 /* Borland C/C++ 4 is `a bit fuzzy' about the next line 8-( */
89 /* if (!(date = makedate(header))) */
90 if ((date
= makedate(header
)) == 0)
93 tm
.tm_sec
= date
->second
;
94 tm
.tm_min
= date
->minute
;
95 tm
.tm_hour
= date
->hour
;
96 tm
.tm_mday
= date
->day
;
97 tm
.tm_mon
= date
->month
- 1;
98 tm
.tm_year
= date
->year
;
99 filetime
= mktime(&tm
);
101 utimbuf
.actime
= filetime
;
102 utimbuf
.modtime
= filetime
;
103 return (utime(filename
, &utimbuf
));