delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/09/24/08:22:29

Date: Tue, 24 Sep 1996 14:17:44 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp-workers AT delorie DOT com
Subject: `utime' which is LFN-aware
Message-Id: <Pine.SUN.3.91.960924141505.11882D-100000@is>
Mime-Version: 1.0

The following changes make possible to set both access time and status 
change time with `utime' (and `utimes') on platforms that support LFN.

*** src/libc/posix/utime/utime.c~0	Mon Feb 27 00:40:24 1995
--- src/libc/posix/utime/utime.c	Sat Sep 21 18:59:28 1996
***************
*** 10,16 ****
  
  /* An implementation of utime() for DJGPP.  The utime() function
     specifies an access time and a modification time.  DOS has only one
!    time, so we will (arbitrarily) use the modification time. */
  int
  utime(const char *path, const struct utimbuf *times)
  {
--- 10,18 ----
  
  /* An implementation of utime() for DJGPP.  The utime() function
     specifies an access time and a modification time.  DOS has only one
!    time, so we will (arbitrarily) use the modification time.
! 
!    IF LFN is supported, then both times are used.  */
  int
  utime(const char *path, const struct utimbuf *times)
  {
***************
*** 19,24 ****
--- 21,27 ----
    time_t modtime;
    int fildes;
    unsigned int dostime, dosdate;
+   int retval = 0, e = 0;
  
    /* DOS wants the file open */
    fildes = open(path, O_RDONLY);
***************
*** 44,52 ****
    r.x.cx = dostime; /* New time */
    r.x.dx = dosdate; /* New date */
    __dpmi_int(0x21, &r);
  
    /* Close the file */
    (void) close(fildes);
  
!   return 0;
  }
--- 47,84 ----
    r.x.cx = dostime; /* New time */
    r.x.dx = dosdate; /* New date */
    __dpmi_int(0x21, &r);
+   if (r.x.flags & 1)
+   {
+     e = EIO;
+     retval = -1;
+   }
+   else if (_USE_LFN)
+   {
+     /* We can set access time as well.  */
+     if (times)
+       modtime = times->actime;
+     tm = localtime(&modtime);
+     dosdate = tm->tm_mday + ((tm->tm_mon + 1) << 5) +
+       ((tm->tm_year - 80) << 9);
+     dostime = tm->tm_sec / 2 + (tm->tm_min << 5) +
+       (tm->tm_hour << 11);
+ 
+     r.x.ax = 0x5705;
+     r.x.bx = fildes;
+     r.x.cx = dostime;	/* this might be ignored */
+     r.x.dx = dosdate;
+     __dpmi_int(0x21, &r);
+     if (r.x.flags & 1)
+     {
+       e = EIO;
+       retval = -1;
+     }
+   }
  
    /* Close the file */
    (void) close(fildes);
+   if (e)
+     errno = e;
  
!   return retval;
  }
*** src/libc/posix/utime/utime.t~0	Mon Jul 10 05:40:58 1995
--- src/libc/posix/utime/utime.txh	Sat Sep 21 19:07:48 1996
***************
*** 15,28 ****
  @example
  struct utimbuf
  @{
!     time_t  actime;  /* access time (unused) */
      time_t  modtime; /* modification time */
  @};
  @end example
  
  Note that, as under DOS a file only has a single timestamp, the
! @code{actime} field of @code{struct utimbuf} is ignored by
! this function, and only @code{modtime} field is used.
  
  @subheading Return Value
  
--- 15,30 ----
  @example
  struct utimbuf
  @{
!     time_t  actime;  /* access time (unused on FAT filesystems) */
      time_t  modtime; /* modification time */
  @};
  @end example
  
  Note that, as under DOS a file only has a single timestamp, the
! @code{actime} field of @code{struct utimbuf} is ignored by this
! function, and only @code{modtime} field is used.  On filesystems which
! support long filenames, both fields are used and both access and
! modification times are set.
  
  @subheading Return Value
  

- Raw text -


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