From af46293ef93a056bcd06f4b8f973fe5aa395d20f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 19 Aug 2011 22:35:15 +0900 Subject: Use utimes instead of utime if utimes is available. --- src/File.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/File.cc') 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 #include -#include +#ifdef HAVE_UTIME_H +# include +#endif // HAVE_UTIME_H #include #include @@ -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() -- cgit