Added debugging option to keep temporary files.
authorBen Hutchings <ben@decadent.org.uk>
Sat, 29 Apr 2006 16:54:15 +0000 (16:54 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 2 Nov 2008 23:39:58 +0000 (23:39 +0000)
temp_file.cpp
temp_file.hpp
webdvd.cpp

index 6b8165c..6dd6c55 100644 (file)
@@ -37,9 +37,12 @@ temp_file::~temp_file()
 {
     close();
 
-    // Don't assert that this is successful.  The file could have
-    // been removed by another process.
-    unlink(name_.c_str());
+    if (!keep_)
+    {
+       // Don't assert that this is successful.  The file could have
+       // been removed by another process.
+       unlink(name_.c_str());
+    }
 }
 
 void temp_file::close()
@@ -51,3 +54,10 @@ void temp_file::close()
        fd_ = -1;
     }
 }
+
+bool temp_file::keep_ = false;
+
+void temp_file::keep_all(bool keep)
+{
+    keep_ = keep;
+}
index 7402fe9..e1d942e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2005 Ben Hutchings <ben@decadentplace.org.uk>.
+// Copyright 2005-6 Ben Hutchings <ben@decadentplace.org.uk>.
 // See the file "COPYING" for licence details.
 
 #ifndef INC_TEMP_FILE_HPP
@@ -17,9 +17,13 @@ public:
     int get_fd() const { return fd_; }
     const std::string & get_name() const { return name_; }
 
+    static void keep_all(bool keep);
+
 private:
     int fd_;
     std::string name_;
+
+    static bool keep_;
 };
 
 #endif // !INC_TEMP_FILE_HPP
index 3c21c28..9c26c8f 100644 (file)
@@ -918,6 +918,11 @@ int main(int argc, char ** argv)
            {
                argi += 2;
            }
+           else if (std::strcmp(argv[argi], "--save-temps") == 0)
+           {
+               temp_file::keep_all(true);
+               argi += 1;
+           }
            else if (argv[argi][0] == '-')
            {
                std::cerr << "Invalid option: " << argv[argi] << "\n";