Move the GetTemporaryDirectory function from "generic Unix" to platform
[oota-llvm.git] / lib / System / Darwin / Path.cpp
index b3321a47dfb6b3a42eff76a84b3b56d5d1e55a64..165bbc64b5ee24457293cbe8d01088aef87b05fd 100644 (file)
@@ -31,6 +31,18 @@ Path::is_valid() const {
   return true;
 }
 
+Path
+Path::GetTemporaryDirectory() {
+  char pathname[MAXPATHLEN];
+  strcpy(pathname,"/tmp/llvm_XXXXXX");
+  if (0 == mkdtemp(pathname))
+    ThrowErrno(std::string(pathname) + ": Can't create temporary directory");
+  Path result;
+  result.set_directory(pathname);
+  assert(result.is_valid() && "mkdtemp didn't create a valid pathname!");
+  return result;
+}
+
 }
 
 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab