delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/08/08/08:55:23

X-Authentication-Warning: new-smtp1.ihug.com.au: Host p40-max50.syd.ihug.com.au [203.173.144.168] claimed to be acceleron
Message-ID: <009801c12008$7b1f98a0$0a02a8c0@acceleron>
From: "Andrew Cottrell" <acottrel AT ihug DOT com DOT au>
To: <djgpp-workers AT delorie DOT com>, "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>,
"Charles Sandmann" <sandmann AT clio DOT rice DOT edu>
Subject: Windows 2000 patch for utime.c v1
Date: Wed, 8 Aug 2001 22:48:52 +1000
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Reply-To: djgpp-workers AT delorie DOT com

Here is my first attempt at a patch to fix the problem with utime under
Windows 2000.

I have added code that is executed if LFN is set and we are not using
Windows 9x. If this code fails then it executes the existing code, but if it
passes then the code exits as it has done it's job.

Should I change the code to execute the new check for all versions of
Windows or only NT or ....?

Andrew


*** utimeold.c Sun Mar 11 00:10:04 2001
--- utime.c Wed Aug  8 22:45:24 2001
***************
*** 1,3 ****
--- 1,4 ----
+ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
***************
*** 8,13 ****
--- 9,16 ----
  #include <errno.h>  /* For errno */
  #include <go32.h>
  #include <dpmi.h>
+ #include <dos.h>
+ #include <libc\dosio.h>

  /* An implementation of utime() for DJGPP.  The utime() function
     specifies an access time and a modification time.  DOS has only one
***************
*** 24,33 ****
    unsigned int dostime, dosdate;
    int retval = 0, e = 0;

-   /* DOS wants the file open */
-   fildes = open(path, O_RDONLY);
-   if (fildes == -1) return -1;
-
    /* NULL times means use current time */
    if (times == NULL)
      modtime = time((time_t *) 0);
--- 27,32 ----
***************
*** 41,46 ****
--- 40,72 ----
    dostime = tm->tm_sec / 2 + (tm->tm_min << 5) +
      (tm->tm_hour << 11);

+
+   if ((_USE_LFN) && ( _osmajor < 7 || _osmajor > 9)) /* LFN & NT */
+   {
+
+      _put_path(path);
+      r.x.ds = __tb_segment;  /* DS:DX -> ASCIZ filename */
+      r.x.dx = __tb_offset;
+
+      r.x.cx = dostime; /* New time */
+      r.x.di = dosdate; /* New date */
+      r.x.si = 0x00;    /* Set to zero just in case */
+
+      r.x.ax = 0x7143;  /* LFN API for extend3ed get/set time */
+      r.x.bx = 0x03;    /* Set last write date / time */
+      __dpmi_int(0x21, &r);
+
+      if (!(r.x.flags & 1))  /* Pass exit otherwise try other methods */
+      {
+          return 0;
+      }
+   }
+
+   /* DOS wants the file open */
+   fildes = open(path, O_RDONLY);
+   if (fildes == -1) return -1;
+
+
    /* Set the file timestamp */
    r.h.ah = 0x57; /* DOS FileTimes call */
    r.h.al = 0x01; /* Set date/time request */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019