Move the GetTemporaryDirectory function from "generic Unix" to platform
[oota-llvm.git] / lib / System / Linux / Path.cpp
index e7efd2fb955ceb5d68cde89e726f62733c3f1b75..8ec35b3c4a4aad7e3fbb64d16c70f9d146f771ba 100644 (file)
@@ -33,6 +33,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