return strDir;
}
-wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile)
+wxString wxFileConfig::GetGlobalFileName(const wxString& file)
{
wxString str = GetGlobalDir();
- str << szFile;
+ str << file;
- if ( wxStrchr(szFile, wxT('.')) == NULL )
+ if ( wxStrchr(file, wxT('.')) == NULL )
#if defined( __WXMAC__ )
str << wxT(" Preferences") ;
#elif defined( __UNIX__ )
return str;
}
-wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
+wxString wxFileConfig::GetLocalFileName(const wxString& file)
{
#ifdef __VMS__
// On VMS I saw the problem that the home directory was appended
str << wxT('.');
#endif
- str << szFile;
+ str << file;
#if defined(__WINDOWS__) || defined(__DOS__)
- if ( wxStrchr(szFile, wxT('.')) == NULL )
+ if ( wxStrchr(file, wxT('.')) == NULL )
str << wxT(".ini");
#endif
{
// Make up names for files if empty
if ( m_strLocalFile.empty() && (style & wxCONFIG_USE_LOCAL_FILE) )
+ {
m_strLocalFile = GetLocalFileName(GetAppName());
+#if defined(__UNIX__) && !defined(__VMS)
+ if ( style & wxCONFIG_USE_SUBDIR )
+ m_strLocalFile << wxFILE_SEP_PATH << GetAppName() << _T(".conf");
+#endif
+ }
if ( m_strGlobalFile.empty() && (style & wxCONFIG_USE_GLOBAL_FILE) )
m_strGlobalFile = GetGlobalFileName(GetAppName());
}
// write all strings to file
+ wxString filetext;
+ filetext.reserve(4096);
for ( wxFileConfigLineList *p = m_linesHead; p != NULL; p = p->Next() )
{
- wxString line = p->Text();
- line += wxTextFile::GetEOL();
- if ( !file.Write(line, *m_conv) )
- {
- wxLogError(_("can't write user configuration file."));
- return false;
- }
+ filetext << p->Text() << wxTextFile::GetEOL();
+ }
+
+ if ( !file.Write(filetext, *m_conv) )
+ {
+ wxLogError(_("can't write user configuration file."));
+ return false;
}
if ( !file.Commit() )