Bläddra i källkod

Merge pull request #1107 from vmarkovtsev/patch-4

Swivel: fastprep: try to create the missing directory
Chris Waterson 8 år sedan
förälder
incheckning
8337978f75
1 ändrade filer med 5 tillägg och 4 borttagningar
  1. 5 4
      swivel/fastprep.cc

+ 5 - 4
swivel/fastprep.cc

@@ -603,10 +603,11 @@ int main(int argc, char *argv[]) {
 
   struct stat sb;
   if (lstat(output_dirname.c_str(), &sb) != 0 || !S_ISDIR(sb.st_mode)) {
-    std::cerr << "output directory '" << output_dirname
-              << "' does not exist of is not a directory." << std::endl;
-
-    return 1;
+    if (mkdir(output_dirname.c_str(), 0755) != 0) {
+      std::cerr << "output directory '" << output_dirname
+                << "' does not exist or is not a directory." << std::endl;
+      return 1;
+    }
   }
 
   if (lstat(input_filename.c_str(), &sb) != 0 || !S_ISREG(sb.st_mode)) {