[cmake-commits] hoffman committed SystemTools.cxx 1.211 1.212
SystemTools.hxx.in 1.67 1.68
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Dec 4 16:03:21 EST 2007
Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv14046/Source/kwsys
Modified Files:
SystemTools.cxx SystemTools.hxx.in
Log Message:
ENH: add a touch -E command to cmake
Index: SystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.cxx,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -d -r1.211 -r1.212
--- SystemTools.cxx 24 Nov 2007 01:45:49 -0000 1.211
+++ SystemTools.cxx 4 Dec 2007 21:03:19 -0000 1.212
@@ -50,6 +50,7 @@
// support for realpath call
#ifndef _WIN32
+#include <utime.h>
#include <limits.h>
#include <sys/param.h>
#include <sys/wait.h>
@@ -75,6 +76,11 @@
# define HAVE_TTY_INFO 1
#endif
+#ifdef _MSC_VER
+#include <sys/utime.h>
+#else
+#include <utime.h>
+#endif
// This is a hack to prevent warnings about these functions being
// declared but not referenced.
@@ -836,6 +842,36 @@
}
}
+bool SystemTools::Touch(const char* filename, bool create)
+{
+ if(create && !SystemTools::FileExists(filename))
+ {
+ FILE* file = fopen(filename, "a+b");
+ if(file)
+ {
+ fclose(file);
+ return true;
+ }
+ return false;
+ }
+#ifdef _MSC_VER
+#define utime _utime
+#define utimbuf _utimbuf
+#endif
+ struct stat fromStat;
+ if(stat(filename, &fromStat) < 0)
+ {
+ return false;
+ }
+ struct utimbuf buf;
+ buf.actime = fromStat.st_atime;
+ buf.modtime = SystemTools::GetTime();
+ if(utime(filename, &buf) < 0)
+ {
+ return false;
+ }
+ return true;
+}
bool SystemTools::FileTimeCompare(const char* f1, const char* f2,
int* result)
Index: SystemTools.hxx.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.hxx.in,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- SystemTools.hxx.in 26 Oct 2007 16:13:01 -0000 1.67
+++ SystemTools.hxx.in 4 Dec 2007 21:03:19 -0000 1.68
@@ -280,6 +280,11 @@
static unsigned long FileLength(const char *filename);
/**
+ Change the modification time or create a file
+ */
+ static bool Touch(const char* filename, bool create);
+
+ /**
* Compare file modification times.
* Return true for successful comparison and false for error.
* When true is returned, result has -1, 0, +1 for
More information about the Cmake-commits
mailing list