fix logfile issue

This commit is contained in:
David Rose 2009-09-26 02:20:26 +00:00
parent cfdc400bcb
commit 4b99d6a3f1
3 changed files with 15 additions and 2 deletions

View File

@ -37,6 +37,8 @@ using namespace std;
extern ostream *nout_stream;
#define nout (*nout_stream)
extern string global_root_dir;
#ifdef _WIN32
// Gecko requires all these symbols to be defined for Windows.

View File

@ -61,7 +61,7 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16 mode,
_tokens.push_back(token);
}
_root_dir = find_root_dir(nout);
_root_dir = global_root_dir;
_got_instance_url = false;
_got_window = false;

View File

@ -24,6 +24,8 @@
static ofstream logfile;
ostream *nout_stream = &logfile;
string global_root_dir;
NPNetscapeFuncs *browser;
static bool logfile_is_open = false;
@ -46,7 +48,7 @@ open_logfile() {
#endif
if (log_directory.empty()) {
#ifdef _WIN32
static const size_t buffer_size = 4096;
static const size_t buffer_size = MAX_PATH;
char buffer[buffer_size];
if (GetTempPath(buffer_size, buffer) != 0) {
log_directory = buffer;
@ -56,6 +58,14 @@ open_logfile() {
#endif // _WIN32
}
// Ensure that the log directory ends with a slash.
if (!log_directory.empty() && log_directory[log_directory.size() - 1] != '/') {
#ifdef _WIN32
if (log_directory[log_directory.size() - 1] != '\\')
#endif
log_directory += "/";
}
// Construct the full logfile pathname.
string log_pathname = log_directory;
log_pathname += log_basename;
@ -138,6 +148,7 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs,
open_logfile();
nout << "initializing\n";
global_root_dir = find_root_dir(nout);
nout << "browserFuncs = " << browserFuncs << "\n";