X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/35c4b4da0a28029dc841147ef6fd183b87d2cc8f..f0e9eda2a55eea7164e872366a1c950a8684c525:/src/common/fileconf.cpp?ds=sidebyside diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index b47cb982a5..7207637f63 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -328,12 +328,12 @@ wxString wxFileConfig::GetLocalDir() 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__ ) @@ -345,7 +345,7 @@ wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile) 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 @@ -360,10 +360,10 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile) 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 @@ -435,7 +435,13 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName, { // 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()); @@ -1041,15 +1047,17 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */) } // 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() )