summaryrefslogtreecommitdiff
path: root/src/File.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-08-19 22:35:15 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-08-19 22:35:15 +0900
commitaf46293ef93a056bcd06f4b8f973fe5aa395d20f (patch)
treec4735fb0c17cc7a844db7fad11a41352d28dbd9b /src/File.cc
parent3fe4e8444375d7b5eb85afce7d9dd6c75cea0f7c (diff)
Use utimes instead of utime if utimes is available.
Diffstat (limited to 'src/File.cc')
-rw-r--r--src/File.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/File.cc b/src/File.cc
index 1fd77ab0..4dfc6cd9 100644
--- a/src/File.cc
+++ b/src/File.cc
@@ -36,7 +36,9 @@
#include <stdlib.h>
#include <sys/types.h>
-#include <utime.h>
+#ifdef HAVE_UTIME_H
+# include <utime.h>
+#endif // HAVE_UTIME_H
#include <unistd.h>
#include <vector>
@@ -218,10 +220,18 @@ bool File::renameTo(const std::string& dest)
bool File::utime(const Time& actime, const Time& modtime) const
{
+#if defined HAVE_UTIMES && !(defined __MINGW32__)
+ struct timeval times[2] = {
+ { actime.getTime(), 0 },
+ { modtime.getTime(), 0 }
+ };
+ return utimes(name_.c_str(), times) == 0;
+#else // !HAVE_UTIMES
a2utimbuf ub;
ub.actime = actime.getTime();
ub.modtime = modtime.getTime();
return a2utime(utf8ToWChar(name_).c_str(), &ub) == 0;
+#endif // !HAVE_UTIMES
}
Time File::getModifiedTime()