From: Ben Hutchings Date: Sat, 29 Apr 2006 16:54:15 +0000 (+0000) Subject: Added debugging option to keep temporary files. X-Git-Tag: 0.7~11 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=392b6372714c8c2b2bf2389b86fb8f47ef70c2ef;p=videolink.git Added debugging option to keep temporary files. --- diff --git a/temp_file.cpp b/temp_file.cpp index 6b8165c..6dd6c55 100644 --- a/temp_file.cpp +++ b/temp_file.cpp @@ -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; +} diff --git a/temp_file.hpp b/temp_file.hpp index 7402fe9..e1d942e 100644 --- a/temp_file.hpp +++ b/temp_file.hpp @@ -1,4 +1,4 @@ -// Copyright 2005 Ben Hutchings . +// Copyright 2005-6 Ben Hutchings . // 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 diff --git a/webdvd.cpp b/webdvd.cpp index 3c21c28..9c26c8f 100644 --- a/webdvd.cpp +++ b/webdvd.cpp @@ -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";