dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/support file.c,1.10,1.11


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/support file.c,1.10,1.11
Date: Fri, 03 Jan 2003 23:42:59 -0500

Update of /cvsroot/dotgnu-pnet/pnet/support
In directory subversions:/tmp/cvs-serv4545/support

Modified Files:
        file.c 
Log Message:
Patch #916 from Aditya Bansod for file time management


Index: file.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/file.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** file.c      25 Dec 2002 04:12:53 -0000      1.10
--- file.c      4 Jan 2003 04:42:57 -0000       1.11
***************
*** 42,45 ****
--- 42,52 ----
        #include <io.h>
  #endif
+ #ifdef HAVE_SYS_UTIME_H
+       #include <sys/utime.h>
+ #else
+ #ifdef HAVE_UTIME_H
+       #include <utime.h>
+ #endif
+ #endif
  
  #ifdef        __cplusplus
***************
*** 442,445 ****
--- 449,542 ----
        }
        return err;
+ }
+ 
+ int ILSysIOSetModificationTime(const char *path, ILInt64 time)
+ {
+ #if defined(HAVE_STAT) && defined(HAVE_UTIME)
+       int retVal;
+       ILInt64 unix_time;
+       struct utimbuf utbuf;
+       struct stat statbuf;
+ 
+       /* Clear errno */
+       errno = 0;
+ 
+       unix_time = ILCLIToUnixTime(time);
+ 
+       /* Grab the old time data first */
+       retVal = stat(path, &statbuf);
+ 
+       if(retVal != 0)
+       {
+               /* Throw out the Errno */
+               return ILSysIOGetErrno();
+       }
+ 
+       /* Copy over the old atime value */
+       utbuf.actime = statbuf.st_atime;
+       
+       /* Set the new mod time */
+       utbuf.modtime = unix_time;
+ 
+       /* And write the inode */
+       retVal = utime(path, &utbuf);
+ 
+       if(retVal != 0)
+       {
+               /* Throw out the errno */
+               return ILSysIOGetErrno();
+       }
+       else
+       {
+               return IL_ERRNO_Success;
+       }
+ #else
+       return IL_ERRNO_ENOSYS;
+ #endif
+ }
+ 
+ int ILSysIOSetAccessTime(const char *path, ILInt64 time)
+ {
+ #if defined(HAVE_STAT) && defined(HAVE_UTIME)
+       int retVal;
+       ILInt64 unix_time;
+       struct utimbuf utbuf;
+       struct stat statbuf;
+ 
+       /* Clear errno */
+       errno = 0;
+ 
+       unix_time = ILCLIToUnixTime(time);
+ 
+       /* Grab the old time data first */
+       retVal = stat(path, &statbuf);
+ 
+       if(retVal != 0)
+       {
+               /* Throw out the Errno */
+               return ILSysIOGetErrno();
+       }
+ 
+       /* Copy over the old mtime value */
+       utbuf.modtime = statbuf.st_mtime;
+       
+       /* Set the new actime time */
+       utbuf.actime = unix_time;
+ 
+       /* And write the inode */
+       retVal = utime(path, &utbuf);
+ 
+       if(retVal != 0)
+       {
+               /* Throw out the errno */
+               return ILSysIOGetErrno();
+       }
+       else
+       {
+               return IL_ERRNO_Success;
+       }
+ #else
+       return IL_ERRNO_ENOSYS;
+ #endif
  }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]