From fdf20a26dba64a6d31dead1e1d19b2d755c0af13 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 14 Aug 2009 00:06:03 +0000 Subject: [PATCH] Allow customizing wxDebugReportCompress output file. It may be useful to change the directory where it is generated to allow the users to find it more quickly. Also allow changing the crash report base name for completeness. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61663 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/debugrpt.h | 13 +++++++++++++ interface/wx/debugrpt.h | 38 ++++++++++++++++++++++++++++++++++++++ src/common/debugrpt.cpp | 18 ++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/include/wx/debugrpt.h b/include/wx/debugrpt.h index 02c895c4e6..c57b27e458 100644 --- a/include/wx/debugrpt.h +++ b/include/wx/debugrpt.h @@ -134,6 +134,15 @@ class WXDLLIMPEXP_QA wxDebugReportCompress : public wxDebugReport public: wxDebugReportCompress() { } + // you can optionally specify the directory and/or name of the file where + // the debug report should be generated, a default location under the + // directory containing temporary files will be used if you don't + // + // both of these functions should be called before Process()ing the report + // if they're called at all + void SetCompressedFileDirectory(const wxString& dir); + void SetCompressedFileBaseName(const wxString& name); + // returns the full path of the compressed file (empty if creation failed) const wxString& GetCompressedFileName() const { return m_zipfile; } @@ -141,6 +150,10 @@ protected: virtual bool DoProcess(); private: + // user-specified file directory/base name, use defaults if empty + wxString m_zipDir, + m_zipName; + // full path to the ZIP file we created wxString m_zipfile; }; diff --git a/interface/wx/debugrpt.h b/interface/wx/debugrpt.h index 7a3a73b9d7..0db0c4dd8f 100644 --- a/interface/wx/debugrpt.h +++ b/interface/wx/debugrpt.h @@ -67,6 +67,44 @@ public: */ wxDebugReportCompress(); + /** + Set the directory where the debug report should be generated. + + By default, the debug report is generated under user temporary files + directory. This is usually fine if it is meant to be processed in some + way (e.g. automatically uploaded to a remote server) but if the user is + asked to manually upload or send the report, it may be more convenient + to generate it in e.g. the users home directory and this function + allows to do this. + + Notice that it should be called before wxDebugReport::Process() or it + has no effect. + + @param dir + The full path to an existing directory where the debug report file + should be generated. + + @since 2.9.1 + */ + void SetCompressedFileDirectory(const wxString& dir); + + /** + Set the base name of the generated debug report file. + + This function is similar to SetCompressedFileDirectory() but allows to + change the base name of the file. Notice that the file extension will + always be @c .zip. + + By default, a unique name constructed from wxApp::GetAppName(), the + current process id and the current date and time is used. + + @param dir + The base name (i.e. without extension) of the file. + + @since 2.9.1 + */ + void SetCompressedFileBaseName(const wxString& name); + /** Returns the full path of the compressed file (empty if creation failed). diff --git a/src/common/debugrpt.cpp b/src/common/debugrpt.cpp index 7a6cb7b604..88beafc6bb 100644 --- a/src/common/debugrpt.cpp +++ b/src/common/debugrpt.cpp @@ -598,6 +598,20 @@ bool wxDebugReport::DoProcess() // wxDebugReportCompress // ---------------------------------------------------------------------------- +void wxDebugReportCompress::SetCompressedFileDirectory(const wxString& dir) +{ + wxASSERT_MSG( m_zipfile.empty(), "Too late: call this before Process()" ); + + m_zipDir = dir; +} + +void wxDebugReportCompress::SetCompressedFileBaseName(const wxString& name) +{ + wxASSERT_MSG( m_zipfile.empty(), "Too late: call this before Process()" ); + + m_zipName = name; +} + bool wxDebugReportCompress::DoProcess() { const size_t count = GetFilesCount(); @@ -609,6 +623,10 @@ bool wxDebugReportCompress::DoProcess() // keep this one: for this we simply treat the directory name as the name // of the file so that its last component becomes our base name wxFileName fn(GetDirectory()); + if ( !m_zipDir.empty() ) + fn.SetPath(m_zipDir); + if ( !m_zipName.empty() ) + fn.SetName(m_zipName); fn.SetExt("zip"); // create the streams -- 2.45.2