1499
1514
* the file, this routine is optional (but most compilers support it).
1517
/* skip restoring time stamps on user's request */
1518
if (uO.D_flag <= 1) {
1502
1519
#ifdef USE_EF_UT_TIME
1503
dos_fdatetime dos_dt;
1520
dos_fdatetime dos_dt;
1506
1523
#endif /* USE_EF_UT_TIME */
1509
1526
/*---------------------------------------------------------------------------
1510
Copy and/or convert time and date variables, if necessary; then set the
1511
file time/date. WEIRD BORLAND "BUG": if output is buffered, and if run
1512
under at least some versions of DOS (e.g., 6.0), and if files are smaller
1513
than DOS physical block size (i.e., 512 bytes) (?), then files MAY NOT
1514
get timestamped correctly--apparently setftime() occurs before any data
1515
are written to the file, and when file is closed and buffers are flushed,
1516
timestamp is overwritten with current time. Even with a 32K buffer, this
1517
does not seem to occur with larger files. UnZip output is now unbuffered,
1518
but if it were not, could still avoid problem by adding "fflush(outfile)"
1519
just before setftime() call. Weird, huh?
1527
Copy and/or convert time and date variables, if necessary; then set
1528
the file time/date. WEIRD BORLAND "BUG": if output is buffered,
1529
and if run under at least some versions of DOS (e.g., 6.0), and if
1530
files are smaller than DOS physical block size (i.e., 512 bytes) (?),
1531
then files MAY NOT get timestamped correctly--apparently setftime()
1532
occurs before any data are written to the file, and when file is
1533
closed and buffers are flushed, timestamp is overwritten with
1534
current time. Even with a 32K buffer, this does not seem to occur
1535
with larger files. UnZip output is now unbuffered, but if it were
1536
not, could still avoid problem by adding "fflush(outfile)" just
1537
before setftime() call. Weird, huh?
1520
1538
---------------------------------------------------------------------------*/
1522
1540
#ifdef USE_EF_UT_TIME
1523
if (G.extra_field &&
1541
if (G.extra_field &&
1524
1542
#ifdef IZ_CHECK_TZ
1527
(ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
1528
G.lrec.last_mod_dos_datetime, &z_utime, NULL)
1531
TTrace((stderr, "close_outfile: Unix e.f. modif. time = %ld\n",
1533
/* round up (down if "up" overflows) to even seconds */
1534
if (z_utime.mtime & 1)
1535
z_utime.mtime = (z_utime.mtime + 1 > z_utime.mtime) ?
1536
z_utime.mtime + 1 : z_utime.mtime - 1;
1537
TIMET_TO_NATIVE(z_utime.mtime) /* NOP unless MSC 7.0 or Macintosh */
1538
t = localtime(&(z_utime.mtime));
1540
t = (struct tm *)NULL;
1541
if (t != (struct tm *)NULL) {
1542
if (t->tm_year < 80) {
1543
dos_dt.z_dtf.zt_se = 0;
1544
dos_dt.z_dtf.zt_mi = 0;
1545
dos_dt.z_dtf.zt_hr = 0;
1546
dos_dt.z_dtf.zd_dy = 1;
1547
dos_dt.z_dtf.zd_mo = 1;
1548
dos_dt.z_dtf.zd_yr = 0;
1545
(ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
1546
G.lrec.last_mod_dos_datetime, &z_utime, NULL)
1549
TTrace((stderr, "close_outfile: Unix e.f. modif. time = %ld\n",
1551
/* round up (down if "up" overflows) to even seconds */
1552
if (z_utime.mtime & 1)
1553
z_utime.mtime = (z_utime.mtime + 1 > z_utime.mtime) ?
1554
z_utime.mtime + 1 : z_utime.mtime - 1;
1555
TIMET_TO_NATIVE(z_utime.mtime) /* NOP unless MSC 7 or Macintosh */
1556
t = localtime(&(z_utime.mtime));
1558
t = (struct tm *)NULL;
1559
if (t != (struct tm *)NULL) {
1560
if (t->tm_year < 80) {
1561
dos_dt.z_dtf.zt_se = 0;
1562
dos_dt.z_dtf.zt_mi = 0;
1563
dos_dt.z_dtf.zt_hr = 0;
1564
dos_dt.z_dtf.zd_dy = 1;
1565
dos_dt.z_dtf.zd_mo = 1;
1566
dos_dt.z_dtf.zd_yr = 0;
1568
dos_dt.z_dtf.zt_se = t->tm_sec >> 1;
1569
dos_dt.z_dtf.zt_mi = t->tm_min;
1570
dos_dt.z_dtf.zt_hr = t->tm_hour;
1571
dos_dt.z_dtf.zd_dy = t->tm_mday;
1572
dos_dt.z_dtf.zd_mo = t->tm_mon + 1;
1573
dos_dt.z_dtf.zd_yr = t->tm_year - 80;
1550
dos_dt.z_dtf.zt_se = t->tm_sec >> 1;
1551
dos_dt.z_dtf.zt_mi = t->tm_min;
1552
dos_dt.z_dtf.zt_hr = t->tm_hour;
1553
dos_dt.z_dtf.zd_dy = t->tm_mday;
1554
dos_dt.z_dtf.zd_mo = t->tm_mon + 1;
1555
dos_dt.z_dtf.zd_yr = t->tm_year - 80;
1576
dos_dt.z_dostime = G.lrec.last_mod_dos_datetime;
1558
dos_dt.z_dostime = G.lrec.last_mod_dos_datetime;
1560
1578
# ifdef __TURBOC__
1561
setftime(fileno(G.outfile), &dos_dt.ft);
1579
setftime(fileno(G.outfile), &dos_dt.ft);
1563
_dos_setftime(fileno(G.outfile), dos_dt.zft.zdate, dos_dt.zft.ztime);
1581
_dos_setftime(fileno(G.outfile), dos_dt.zft.zdate, dos_dt.zft.ztime);
1565
1583
#else /* !USE_EF_UT_TIME */
1566
1584
# ifdef __TURBOC__
1567
setftime(fileno(G.outfile),
1568
(struct ftime *)(&(G.lrec.last_mod_dos_datetime)));
1585
setftime(fileno(G.outfile),
1586
(struct ftime *)(&(G.lrec.last_mod_dos_datetime)));
1570
_dos_setftime(fileno(G.outfile), (ush)(G.lrec.last_mod_dos_datetime >> 16),
1571
(ush)(G.lrec.last_mod_dos_datetime));
1588
_dos_setftime(fileno(G.outfile),
1589
(ush)(G.lrec.last_mod_dos_datetime >> 16),
1590
(ush)(G.lrec.last_mod_dos_datetime));
1573
1592
#endif /* ?USE_EF_UT_TIME */
1575
1595
/*---------------------------------------------------------------------------
1576
1596
And finally we can close the file...at least everybody agrees on how to
1797
/**************************************/
1798
/* Function is_running_on_windows() */
1799
/**************************************/
1801
static int is_running_on_windows(void)
1803
char *var = getenv("OS");
1805
/* if the OS env.var says 'Windows_NT' then */
1806
/* we're likely running on a variant of WinNT */
1807
if ((var != NULL) && (strcmp("Windows_NT", var) == 0))
1810
/* if the windir env.var is non-null then */
1811
/* we're likely running on a variant of Win9x */
1812
/* DOS mode of Win9x doesn't define windir, only winbootdir */
1813
/* NT's command.com can't see lowercase env. vars */
1814
var = getenv("windir");
1815
if ((var != NULL) && (var[0] != '\0'))
1822
/**********************************/
1823
/* Function check_for_windows() */
1824
/**********************************/
1826
void check_for_windows(ZCONST char *app)
1829
char msg_str[160]; /* enough space for two 79-char-lines */
1831
(void)zfstrcpy(msg_buf, WarnUsedOnWindows)
1833
# define msg_str WarnUsedOnWindows
1835
/* Print a warning for users running under Windows */
1836
/* to reduce bug reports due to running DOS version */
1837
/* under Windows, when Windows version usually works correctly */
1838
if (is_running_on_windows())
1839
printf(msg_str, app);
1840
} /* end function check_for_windows() */
1737
1843
/************************/
1738
1844
/* Function version() */
1739
1845
/************************/