From 28c407296060be0a891922427a7a16b80196b50f Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Jun 2010 20:37:46 +0200 Subject: [PATCH] Changed: #991 Make sure all debug files are created in log directory --- code/nel/include/nel/misc/path.h | 6 ++++++ .../driver/opengl/driver_opengl_vertex_program.cpp | 2 +- code/nel/src/misc/path.cpp | 13 +++++++++++++ code/nel/src/misc/report.cpp | 13 +++++-------- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/code/nel/include/nel/misc/path.h b/code/nel/include/nel/misc/path.h index 2038d21eb..004156750 100644 --- a/code/nel/include/nel/misc/path.h +++ b/code/nel/include/nel/misc/path.h @@ -561,6 +561,12 @@ struct CFile */ static bool isExists (const std::string& filename); + /** + * Create an empty file. + * Return true if the file has been correctly created. + */ + static bool createEmptyFile (const std::string& filename); + /** * Return a new filename that doesn't exists. It's used for screenshot filename for example. * example: findNewFile("foobar.tga"); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp index 125654ad4..6562e62c1 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp @@ -1535,7 +1535,7 @@ bool CDriverGL::activeEXTVertexShader (CVertexProgram *program) } /* - FILE *f = fopen("c:\\test.txt", "wb"); + FILE *f = fopen(getLogDirectory() + "test.txt", "wb"); if (f) { std::string vpText; diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index ec65ab8be..e0d11a0fc 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1755,6 +1755,19 @@ bool CFile::isExists (const string &filename) #endif // NL_OS_WINDOWS } +bool CFile::createEmptyFile (const std::string& filename) +{ + FILE *file = fopen (filename.c_str(), "wb"); + + if (file) + { + fclose (file); + return true; + } + + return false; +} + bool CFile::fileExists (const string& filename) { //H_AUTO(FileExists); diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index e8ed04115..594e00caa 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -22,6 +22,7 @@ #include "nel/misc/ucstring.h" #include "nel/misc/report.h" +#include "nel/misc/path.h" #ifdef NL_OS_WINDOWS # define NOMINMAX @@ -95,15 +96,13 @@ static void sendEmail() // EnableWindow(sendReport, FALSE); // MessageBox (dialog, "The email was successfully sent", "email", MB_OK); #ifndef NL_NO_DEBUG_FILES - FILE *file = fopen ("report_sent", "wb"); - fclose (file); + CFile::createEmptyFile(getLogDirectory() + "report_sent"); #endif } else { #ifndef NL_NO_DEBUG_FILES - FILE *file = fopen ("report_failed", "wb"); - fclose (file); + CFile::createEmptyFile(getLogDirectory() + "report_failed"); #endif // MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); } @@ -111,8 +110,7 @@ static void sendEmail() else { #ifndef NL_NO_DEBUG_FILES - FILE *file = fopen ("report_refused", "wb"); - fclose (file); + CFile::createEmptyFile(getLogDirectory() + "report_refused"); #endif } } @@ -171,8 +169,7 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM { EnableWindow(sendReport, FALSE); MessageBox (dialog, "The email was successfully sent", "email", MB_OK); - FILE *file = fopen ("report_sent", "wb"); - fclose (file); + CFile::createEmptyFile(getLogDirectory() + "report_sent"); } else {