[Cmake-commits] [cmake-commits] king committed cmSystemTools.cxx 1.374 1.375 cmSystemTools.h 1.150 1.151
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Apr 14 11:43:49 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv1598/Source
Modified Files:
cmSystemTools.cxx cmSystemTools.h
Log Message:
ENH: Added methods to cmSystemTools to save and restore file modification times.
Index: cmSystemTools.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.h,v
retrieving revision 1.150
retrieving revision 1.151
diff -C 2 -d -r1.150 -r1.151
*** cmSystemTools.h 2 Mar 2008 19:35:23 -0000 1.150
--- cmSystemTools.h 14 Apr 2008 15:43:45 -0000 1.151
***************
*** 23,27 ****
#include <cmsys/Process.h>
!
/** \class cmSystemTools
--- 23,27 ----
#include <cmsys/Process.h>
! class cmSystemToolsFileTime;
/** \class cmSystemTools
***************
*** 364,367 ****
--- 364,373 ----
static bool CopyFileTime(const char* fromFile, const char* toFile);
+ /** Save and restore file times. */
+ static cmSystemToolsFileTime* FileTimeNew();
+ static void FileTimeDelete(cmSystemToolsFileTime*);
+ static bool FileTimeGet(const char* fname, cmSystemToolsFileTime* t);
+ static bool FileTimeSet(const char* fname, cmSystemToolsFileTime* t);
+
/** Find the directory containing the running executable. Save it
in a global location to be queried by GetExecutableDirectory
Index: cmSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.cxx,v
retrieving revision 1.374
retrieving revision 1.375
diff -C 2 -d -r1.374 -r1.375
*** cmSystemTools.cxx 8 Apr 2008 21:37:13 -0000 1.374
--- cmSystemTools.cxx 14 Apr 2008 15:43:44 -0000 1.375
***************
*** 57,60 ****
--- 57,72 ----
#endif
+ class cmSystemToolsFileTime
+ {
+ public:
+ #if defined(_WIN32) && !defined(__CYGWIN__)
+ FILETIME timeCreation;
+ FILETIME timeLastAccess;
+ FILETIME timeLastWrite;
+ #else
+ struct utimbuf timeBuf;
+ #endif
+ };
+
#if defined(__sgi) && !defined(__GNUC__)
# pragma set woff 1375 /* base class destructor not virtual */
***************
*** 2112,2115 ****
--- 2124,2188 ----
//----------------------------------------------------------------------------
+ cmSystemToolsFileTime* cmSystemTools::FileTimeNew()
+ {
+ return new cmSystemToolsFileTime;
+ }
+
+ //----------------------------------------------------------------------------
+ void cmSystemTools::FileTimeDelete(cmSystemToolsFileTime* t)
+ {
+ delete t;
+ }
+
+ //----------------------------------------------------------------------------
+ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
+ {
+ #if defined(_WIN32) && !defined(__CYGWIN__)
+ cmSystemToolsWindowsHandle h =
+ CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
+ if(!h)
+ {
+ return false;
+ }
+ if(!GetFileTime(h, &t->timeCreation, &t->timeLastAccess, &t->timeLastWrite))
+ {
+ return false;
+ }
+ #else
+ struct stat st;
+ if(stat(fname, &st) < 0)
+ {
+ return false;
+ }
+ t->timeBuf.actime = st.st_atime;
+ t->timeBuf.modtime = st.st_mtime;
+ #endif
+ return true;
+ }
+
+ //----------------------------------------------------------------------------
+ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t)
+ {
+ #if defined(_WIN32) && !defined(__CYGWIN__)
+ cmSystemToolsWindowsHandle h =
+ CreateFile(toFile, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
+ if(!h)
+ {
+ return false;
+ }
+ if(!SetFileTime(h, &t->timeCreation, &t->timeLastAccess, &t->timeLastWrite))
+ {
+ return false;
+ }
+ #else
+ if(utime(fname, &t->timeBuf) < 0)
+ {
+ return false;
+ }
+ #endif
+ return true;
+ }
+
+ //----------------------------------------------------------------------------
static std::string cmSystemToolsExecutableDirectory;
void cmSystemTools::FindExecutableDirectory(const char* argv0)
More information about the Cmake-commits
mailing list