Build fix for Android NDK which has neither futimes nor futimens
authorAlp Toker <alp@nuanti.com>
Wed, 11 Dec 2013 15:42:33 +0000 (15:42 +0000)
committerAlp Toker <alp@nuanti.com>
Wed, 11 Dec 2013 15:42:33 +0000 (15:42 +0000)
Based on a patch by Neil Henning!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197045 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/FileSystem.h
lib/Support/Unix/Path.inc

index d301f842ea9f982800a5e979dfca36721392e2b8..bf2e514d409b6c27f9f67dd812bee1f71f24f37b 100644 (file)
@@ -545,6 +545,11 @@ inline error_code file_size(const Twine &Path, uint64_t &Result) {
   return error_code::success();
 }
 
+/// @brief Set the file modification and access time.
+///
+/// @returns errc::success if the file times were successfully set, otherwise a
+///          platform specific error_code or errc::not_supported on platforms
+///          where the functionality isn't available.
 error_code setLastModificationAndAccessTime(int FD, TimeValue Time);
 
 /// @brief Is status available?
index 734ea5d110a96332efcd4e247d6e1c6e86a66cfb..d52604246169a591f999cb120d794fa8cce187d4 100644 (file)
@@ -531,17 +531,20 @@ error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
   Times[0].tv_nsec = 0;
   Times[1] = Times[0];
   if (::futimens(FD, Times))
+    return error_code(errno, system_category());
+  return error_code::success();
 #elif defined(HAVE_FUTIMES)
   timeval Times[2];
   Times[0].tv_sec = Time.toPosixTime();
   Times[0].tv_usec = 0;
   Times[1] = Times[0];
   if (::futimes(FD, Times))
-#else
-#error Missing futimes() and futimens()
-#endif
     return error_code(errno, system_category());
   return error_code::success();
+#else
+#warning Missing futimes() and futimens()
+  return make_error_code(errc::not_supported);
+#endif
 }
 
 error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) {