]> git.decadent.org.uk Git - videolink.git/commitdiff
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 6b8165c1541ec97bd6b635fbde9886c31abd406c..6dd6c555fcd62fd4725ac64a57c5498ce77eaa94 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 7402fe90df6044f17b8160a1aff9dbdd45caf526..e1d942efa0ecbd06b308f760af3394bc9c8abb94 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 3c21c28dfe254997d53c819245097d591f6dfc5e..9c26c8fb20ef13df89ffc2ab9c6ea34a57c46282 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";