Changed: #991 Make sure all debug files are created in log directory

This commit is contained in:
kervala 2010-06-21 20:37:46 +02:00
parent f5f7c53a40
commit d089919c2f
4 changed files with 25 additions and 9 deletions

View file

@ -561,6 +561,12 @@ struct CFile
*/ */
static bool isExists (const std::string& filename); 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. * Return a new filename that doesn't exists. It's used for screenshot filename for example.
* example: findNewFile("foobar.tga"); * example: findNewFile("foobar.tga");

View file

@ -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) if (f)
{ {
std::string vpText; std::string vpText;

View file

@ -1755,6 +1755,19 @@ bool CFile::isExists (const string &filename)
#endif // NL_OS_WINDOWS #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) bool CFile::fileExists (const string& filename)
{ {
//H_AUTO(FileExists); //H_AUTO(FileExists);

View file

@ -22,6 +22,7 @@
#include "nel/misc/ucstring.h" #include "nel/misc/ucstring.h"
#include "nel/misc/report.h" #include "nel/misc/report.h"
#include "nel/misc/path.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# define NOMINMAX # define NOMINMAX
@ -95,15 +96,13 @@ static void sendEmail()
// EnableWindow(sendReport, FALSE); // EnableWindow(sendReport, FALSE);
// MessageBox (dialog, "The email was successfully sent", "email", MB_OK); // MessageBox (dialog, "The email was successfully sent", "email", MB_OK);
#ifndef NL_NO_DEBUG_FILES #ifndef NL_NO_DEBUG_FILES
FILE *file = fopen ("report_sent", "wb"); CFile::createEmptyFile(getLogDirectory() + "report_sent");
fclose (file);
#endif #endif
} }
else else
{ {
#ifndef NL_NO_DEBUG_FILES #ifndef NL_NO_DEBUG_FILES
FILE *file = fopen ("report_failed", "wb"); CFile::createEmptyFile(getLogDirectory() + "report_failed");
fclose (file);
#endif #endif
// MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); // MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR);
} }
@ -111,8 +110,7 @@ static void sendEmail()
else else
{ {
#ifndef NL_NO_DEBUG_FILES #ifndef NL_NO_DEBUG_FILES
FILE *file = fopen ("report_refused", "wb"); CFile::createEmptyFile(getLogDirectory() + "report_refused");
fclose (file);
#endif #endif
} }
} }
@ -171,8 +169,7 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM
{ {
EnableWindow(sendReport, FALSE); EnableWindow(sendReport, FALSE);
MessageBox (dialog, "The email was successfully sent", "email", MB_OK); MessageBox (dialog, "The email was successfully sent", "email", MB_OK);
FILE *file = fopen ("report_sent", "wb"); CFile::createEmptyFile(getLogDirectory() + "report_sent");
fclose (file);
} }
else else
{ {