Windows: Moved `os::utime` to its own file, `stout/os/utime.hpp`.

Review: https://reviews.apache.org/r/39537


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/522517e5
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/522517e5
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/522517e5

Branch: refs/heads/master
Commit: 522517e551af0a14ff12ba51151533d42ce7686e
Parents: 8fe7997
Author: Alex Clemmer <[email protected]>
Authored: Mon Oct 26 13:09:42 2015 -0400
Committer: Joris Van Remoortere <[email protected]>
Committed: Wed Oct 28 17:11:03 2015 -0500

----------------------------------------------------------------------
 .../3rdparty/stout/include/Makefile.am          |  1 +
 .../3rdparty/stout/include/stout/os.hpp         | 12 +----
 .../3rdparty/stout/include/stout/os/utime.hpp   | 48 ++++++++++++++++++++
 3 files changed, 50 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/522517e5/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am 
b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index ba2836a..d2b6fe8 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -90,6 +90,7 @@ nobase_include_HEADERS =              \
   stout/os/permissions.hpp             \
   stout/os/pstree.hpp                  \
   stout/os/sysctl.hpp                  \
+  stout/os/utime.hpp                   \
   stout/os/write.hpp                   \
   stout/os/raw/environment.hpp         \
   stout/os/windows/bootid.hpp          \

http://git-wip-us.apache.org/repos/asf/mesos/blob/522517e5/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp 
b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index 7f70c9e..95bdb0f 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -89,6 +89,7 @@
 #include <stout/os/shell.hpp>
 #include <stout/os/signals.hpp>
 #include <stout/os/stat.hpp>
+#include <stout/os/utime.hpp>
 #include <stout/os/write.hpp>
 
 
@@ -133,17 +134,6 @@ inline Try<bool> access(const std::string& path, int how)
 }
 
 
-// Sets the access and modification times of 'path' to the current time.
-inline Try<Nothing> utime(const std::string& path)
-{
-  if (::utime(path.c_str(), NULL) == -1) {
-    return ErrnoError();
-  }
-
-  return Nothing();
-}
-
-
 // Creates a temporary file using the specified path template. The
 // template may be any path with _6_ `Xs' appended to it, for example
 // /tmp/temp.XXXXXX. The trailing `Xs' are replaced with a unique

http://git-wip-us.apache.org/repos/asf/mesos/blob/522517e5/3rdparty/libprocess/3rdparty/stout/include/stout/os/utime.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/utime.hpp 
b/3rdparty/libprocess/3rdparty/stout/include/stout/os/utime.hpp
new file mode 100644
index 0000000..e98f673
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/utime.hpp
@@ -0,0 +1,48 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_OS_UTIME_HPP__
+#define __STOUT_OS_UTIME_HPP__
+
+#include <string>
+
+#ifdef __WINDOWS__
+#include <sys/utime.h>
+#else
+#include <utime.h>
+#endif // __WINDOWS__
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+
+namespace os {
+
+// Sets the access and modification times of 'path' to the current time.
+inline Try<Nothing> utime(const std::string& path)
+{
+  // NOTE: on Windows, this correctly dispatches to `_utime`, so there is no
+  // need to create a function alias in `stout/windows.hpp` as we have done for
+  // `stout/os/mkdir.hpp` and friends.
+  if (::utime(path.c_str(), NULL) == -1) {
+    return ErrnoError();
+  }
+
+  return Nothing();
+}
+
+} // namespace os {
+
+
+#endif // __STOUT_OS_UTIME_HPP__

Reply via email to