]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fileconf.cpp
Made choice convenient dialog more, well, convenient: fixed lack of vertical
[wxWidgets.git] / src / common / fileconf.cpp
index c8688763011806944c34b6e6f1fcc996a989d5dc..7207637f634d54b4aef68f236e6f185f3d19964e 100644 (file)
@@ -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
 
@@ -439,7 +439,7 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
         m_strLocalFile = GetLocalFileName(GetAppName());
 #if defined(__UNIX__) && !defined(__VMS)
         if ( style & wxCONFIG_USE_SUBDIR )
-            m_strLocalFile << wxFILE_SEP_PATH << GetAppName();
+            m_strLocalFile << wxFILE_SEP_PATH << GetAppName() << _T(".conf");
 #endif
     }
 
@@ -1047,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() )