X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..8472511246c9160d4ff40ab86f635fc67c10b54a:/src/common/debugrpt.cpp diff --git a/src/common/debugrpt.cpp b/src/common/debugrpt.cpp index 85a8a2f6c8..3d4f505412 100644 --- a/src/common/debugrpt.cpp +++ b/src/common/debugrpt.cpp @@ -6,7 +6,7 @@ // Created: 2005-01-17 // RCS-ID: $Id$ // Copyright: (c) 2005 Vadim Zeitlin -// License: wxWindows licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -188,16 +188,14 @@ wxDebugReport::wxDebugReport() // directory, so do our best to create a unique name ourselves // // of course, this doesn't protect us against malicious users... - wxFileName fn; - fn.AssignTempFileName(appname); #if wxUSE_DATETIME m_dir.Printf(wxT("%s%c%s_dbgrpt-%lu-%s"), - fn.GetPath().c_str(), wxFILE_SEP_PATH, appname.c_str(), + wxFileName::GetTempDir(), wxFILE_SEP_PATH, appname, wxGetProcessId(), - wxDateTime::Now().Format(wxT("%Y%m%dT%H%M%S")).c_str()); + wxDateTime::Now().Format(wxT("%Y%m%dT%H%M%S"))); #else m_dir.Printf(wxT("%s%c%s_dbgrpt-%lu"), - fn.GetPath().c_str(), wxFILE_SEP_PATH, appname.c_str(), + wxFileName::GetTempDir(), wxFILE_SEP_PATH, appname, wxGetProcessId()); #endif @@ -252,8 +250,8 @@ wxDebugReport::~wxDebugReport() wxString wxDebugReport::GetReportName() const { - if(wxTheApp) - return wxTheApp->GetAppDisplayName(); + if ( wxTheApp ) + return wxTheApp->GetAppName(); return wxT("wx"); } @@ -268,8 +266,10 @@ wxDebugReport::AddFile(const wxString& filename, const wxString& description) // we need to copy the file to the debug report directory: give it the // same name there name = fn.GetFullName(); - wxCopyFile(fn.GetFullPath(), - wxFileName(GetDirectory(), name).GetFullPath()); + + if (!wxCopyFile(fn.GetFullPath(), + wxFileName(GetDirectory(), name).GetFullPath())) + return; } else // file relative to the report directory { @@ -598,14 +598,38 @@ 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(); if ( !count ) return false; + // create the compressed report file outside of the directory with the + // report files as it will be deleted by wxDebugReport dtor but we want to + // 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 - wxFileName fn(GetDirectory(), GetReportName(), wxT("zip")); wxFFileOutputStream os(fn.GetFullPath(), wxT("wb")); wxZipOutputStream zos(os, 9); @@ -621,7 +645,7 @@ bool wxDebugReportCompress::DoProcess() if ( !zos.PutNextEntry(ze) ) return false; - wxFileName filename(fn.GetPath(), name); + const wxFileName filename(GetDirectory(), name); wxFFileInputStream is(filename.GetFullPath()); if ( !is.IsOk() || !zos.Write(is).IsOk() ) return false; @@ -661,7 +685,7 @@ bool wxDebugReportUpload::DoProcess() wxArrayString output, errors; int rc = wxExecute(wxString::Format ( - wxT("%s -F %s=@\"%s\" %s"), + wxT("%s -F \"%s=@%s\" %s"), m_curlCmd.c_str(), m_inputField.c_str(), GetCompressedFileName().c_str(),