]> granicus.if.org Git - llvm/commitdiff
[libFuzzer] Implement TmpDir() for Windows.
authorMarcos Pividori <mpividori@google.com>
Mon, 30 Jan 2017 18:14:53 +0000 (18:14 +0000)
committerMarcos Pividori <mpividori@google.com>
Mon, 30 Jan 2017 18:14:53 +0000 (18:14 +0000)
Differential Revision: https://reviews.llvm.org/D28977

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

lib/Fuzzer/FuzzerIOWindows.cpp

index 84941bae28f0229a317843aadba73e0905d09a4a..536e130672557b6ad2b0c77a215bffc2c8156a17 100644 (file)
@@ -287,7 +287,17 @@ std::string DirName(const std::string &FileName) {
   return FileName.substr(0, LocationLen + DirLen);
 }
 
-std::string TmpDir() { return "TODO: implement TmpDir"; }
+std::string TmpDir() {
+  std::string Tmp;
+  Tmp.resize(MAX_PATH + 1);
+  DWORD Size = GetTempPathA(Tmp.size(), &Tmp[0]);
+  if (Size == 0) {
+    Printf("Couldn't get Tmp path.\n");
+    exit(1);
+  }
+  Tmp.resize(Size);
+  return Tmp;
+}
 
 bool IsInterestingCoverageFile(const std::string &FileName) {
   if (FileName.find("Program Files") != std::string::npos)