You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/10/27 00:07:17 UTC
svn commit: r1402694 -
/incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp
Author: benh
Date: Fri Oct 26 22:07:17 2012
New Revision: 1402694
URL: http://svn.apache.org/viewvc?rev=1402694&view=rev
Log:
Updated os::mktemp and os::mkdtemp to take a templated string rather
than just a "root" directory.
Review: https://reviews.apache.org/r/7717
Modified:
incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp
Modified: incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp?rev=1402694&r1=1402693&r2=1402694&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp Fri Oct 26 22:07:17 2012
@@ -187,12 +187,13 @@ inline Try<Nothing> touch(const std::str
}
-// Creates a temporary file under 'root' directory and returns its path.
-inline Try<std::string> mktemp(const std::string& root = "/tmp")
+// 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
+// alphanumeric combination.
+inline Try<std::string> mktemp(const std::string& path = "/tmp/XXXXXX")
{
- const std::string path = path::join(root, "XXXXXX");
char* temp = new char[path.size() + 1];
-
if (::mktemp(::strcpy(temp, path.c_str())) != NULL) {
std::string result(temp);
delete temp;
@@ -431,12 +432,13 @@ inline Try<Nothing> mkdir(const std::str
return Nothing();
}
-// Creates a temporary directory under 'root' directory and returns its path.
-inline Try<std::string> mkdtemp(const std::string& root = "/tmp")
+// Creates a temporary directory 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 alphanumeric combination.
+inline Try<std::string> mkdtemp(const std::string& path = "/tmp/XXXXXX")
{
- const std::string path = path::join(root, "XXXXXX");
char* temp = new char[path.size() + 1];
-
if (::mkdtemp(::strcpy(temp, path.c_str())) != NULL) {
std::string result(temp);
delete temp;