From 03915200af8bdd99789a8b478969deff68b5d0ef Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 18 Jun 2015 23:22:13 +0200 Subject: [PATCH] Use the hosts file in debugrpt sample under all systems. Attach the hosts file under all platforms to the debug report: this makes more sense the hosts file could be potentially useful, unlike autoexec.bat and /etc/motd that were used before, is also consistent between the platforms and, finally, avoids the error due to autoexec.bat not existing any more in the modern Windows versions. Closes #16655. --- samples/debugrpt/debugrpt.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/samples/debugrpt/debugrpt.cpp b/samples/debugrpt/debugrpt.cpp index 235eafc227..cb136be70c 100644 --- a/samples/debugrpt/debugrpt.cpp +++ b/samples/debugrpt/debugrpt.cpp @@ -369,10 +369,20 @@ void MyApp::GenerateReport(wxDebugReport::Context ctx) // can also add an existing file directly, it will be copied // automatically #ifdef __WXMSW__ - report->AddFile(wxT("c:\\autoexec.bat"), wxT("DOS startup file")); -#else - report->AddFile(wxT("/etc/motd"), wxT("Message of the day")); -#endif + wxString windir; + if ( !wxGetEnv("WINDIR", &windir) ) + windir = "C:\\Windows"; + fn.AssignDir(windir); + fn.AppendDir("system32"); + fn.AppendDir("drivers"); + fn.AppendDir("etc"); +#else // !__WXMSW__ + fn.AssignDir("/etc"); +#endif // __WXMSW__/!__WXMSW__ + fn.SetFullName("hosts"); + + if ( fn.FileExists() ) + report->AddFile(fn.GetFullPath(), "Local hosts file"); // calling Show() is not mandatory, but is more polite if ( wxDebugReportPreviewStd().Show(*report) )