|
From: <pst...@us...> - 2008-11-15 23:18:38
|
Revision: 629
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=629&view=rev
Author: pstieber
Date: 2008-11-15 23:18:35 +0000 (Sat, 15 Nov 2008)
Log Message:
-----------
Changed JZConfiguration::GetFileName() to look for the Jazz++ configuration file under
the user data directory for Jazz++.
Modified Paths:
--------------
trunk/jazz/src/Configuration.cpp
trunk/jazz/src/Configuration.h
Modified: trunk/jazz/src/Configuration.cpp
===================================================================
--- trunk/jazz/src/Configuration.cpp 2008-11-15 23:16:27 UTC (rev 628)
+++ trunk/jazz/src/Configuration.cpp 2008-11-15 23:18:35 UTC (rev 629)
@@ -22,6 +22,7 @@
#include "WxWidgets.h"
+#include <wx/stdpaths.h>
#include <wx/filename.h>
#include "Configuration.h"
@@ -115,7 +116,6 @@
}
}
-
//*****************************************************************************
// Description:
// This is the configuration class definition.
@@ -440,9 +440,7 @@
//-----------------------------------------------------------------------------
// Description:
-// Return the Jazz++ configuration file name, normally jazz.cfg. If the
-// value has not been set by an earlier call to LoadConfig, attempt to find
-// the file using FindFile().
+// Return the Jazz++ configuration file name, normally jazz.cfg.
//-----------------------------------------------------------------------------
wxString JZConfiguration::GetFileName()
{
@@ -451,11 +449,16 @@
return mFileName;
}
- mFileName = FindFile("jazz.cfg");
+ wxString ConfigDir = wxStandardPaths::Get().GetUserDataDir();
- if (mFileName.empty())
+ wxString JazzCfgFile =
+ ConfigDir +
+ wxFileName::GetPathSeparator() +
+ "jazz.cfg";
+
+ if (::wxFileExists(JazzCfgFile))
{
- mFileName = FindFile(".jazz");
+ mFileName = JazzCfgFile;
}
return mFileName;
@@ -607,25 +610,28 @@
}
// Create a temporary file name from the current file name.
+// wxFileName TempFileName = wxFileName::CreateTempFileName(wxEmptyString);
+
string TempFileName(FileName);
TempFileName.append(".tmp");
ofstream Os(TempFileName.c_str());
+// ofstream Os(TempFileName.GetFullPath());
if (!Os)
{
return false;
}
FILE* inp = fopen(FileName.c_str(), "r");
- const string& name = GetName(Index);
+ const string& ValueName = GetName(Index);
- int len = name.length();
+ int len = ValueName.length();
char buf[1000];
bool found = false;
while (fgets(buf, sizeof(buf), inp) != NULL)
{
- if (strncmp(buf, name.c_str(), len) == 0)
+ if (strncmp(buf, ValueName.c_str(), len) == 0)
{
- Os << name << ' ' << ValueString << endl;
+ Os << ValueName << ' ' << ValueString << endl;
found = true;
}
else
@@ -635,13 +641,14 @@
}
if (!found)
{
- Os << name << ' ' << ValueString << endl;
+ Os << ValueName << ' ' << ValueString << endl;
}
fclose(inp);
Os.close();
- unlink(FileName.c_str());
- rename(TempFileName.c_str(), FileName.c_str());
+ ::wxRemoveFile(FileName.c_str());
+ ::wxRenameFile(TempFileName, FileName);
+
return true;
}
Modified: trunk/jazz/src/Configuration.h
===================================================================
--- trunk/jazz/src/Configuration.h 2008-11-15 23:16:27 UTC (rev 628)
+++ trunk/jazz/src/Configuration.h 2008-11-15 23:18:35 UTC (rev 629)
@@ -254,9 +254,7 @@
private:
// Description:
- // Return the Jazz++ configuration file name, normally jazz.cfg. If the
- // value has not been set by an earlier call to LoadConfig, attempt to
- // find the file using FindFile().
+ // Return the Jazz++ configuration file name, normally jazz.cfg.
wxString GetFileName();
private:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|