X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a7ad2611f33165ef9daa0e566640b43e4f03cb83..4aaef122cbbd5bbe0e70b824e320458e2329dd13:/src/common/fileconf.cpp?ds=inline diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 88376df785..a6107188c9 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -274,90 +274,14 @@ wxString wxFileConfig::GetGlobalDir() if (rc == 0) { drive = aulSysInfo[QSV_BOOT_DRIVE - 1]; - switch(drive) - { - case 1: - strDir = "A:\\OS2\\"; - break; - case 2: - strDir = "B:\\OS2\\"; - break; - case 3: - strDir = "C:\\OS2\\"; - break; - case 4: - strDir = "D:\\OS2\\"; - break; - case 5: - strDir = "E:\\OS2\\"; - break; - case 6: - strDir = "F:\\OS2\\"; - break; - case 7: - strDir = "G:\\OS2\\"; - break; - case 8: - strDir = "H:\\OS2\\"; - break; - case 9: - strDir = "I:\\OS2\\"; - break; - case 10: - strDir = "J:\\OS2\\"; - break; - case 11: - strDir = "K:\\OS2\\"; - break; - case 12: - strDir = "L:\\OS2\\"; - break; - case 13: - strDir = "M:\\OS2\\"; - break; - case 14: - strDir = "N:\\OS2\\"; - break; - case 15: - strDir = "O:\\OS2\\"; - break; - case 16: - strDir = "P:\\OS2\\"; - break; - case 17: - strDir = "Q:\\OS2\\"; - break; - case 18: - strDir = "R:\\OS2\\"; - break; - case 19: - strDir = "S:\\OS2\\"; - break; - case 20: - strDir = "T:\\OS2\\"; - break; - case 21: - strDir = "U:\\OS2\\"; - break; - case 22: - strDir = "V:\\OS2\\"; - break; - case 23: - strDir = "W:\\OS2\\"; - break; - case 24: - strDir = "X:\\OS2\\"; - break; - case 25: - strDir = "Y:\\OS2\\"; - break; - case 26: - strDir = "Z:\\OS2\\"; - break; - } + strDir.Printf(wxT("%c:\\OS2\\"), 'A'+drive-1); } #elif defined(__WXSTUBS__) wxASSERT_MSG( FALSE, wxT("TODO") ) ; + #elif defined(__DOS__) + // There's no such thing as global cfg dir in MS-DOS, let's return + // current directory (FIXME_MGL?) + return wxT(".\\"); #else // Windows wxChar szWinDir[MAX_PATH]; ::GetWindowsDirectory(szWinDir, MAX_PATH); @@ -373,8 +297,8 @@ wxString wxFileConfig::GetLocalDir() { wxString strDir; -#if defined(__WXMAC__) - // no local dir concept on Mac OS 9 +#if defined(__WXMAC__) || defined(__DOS__) + // no local dir concept on Mac OS 9 or MS-DOS return GetGlobalDir() ; #else wxGetHomeDir(&strDir); @@ -425,7 +349,7 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile) str << szFile; - #ifdef __WXMSW__ + #if defined(__WINDOWS__) || defined(__DOS__) if ( wxStrchr(szFile, wxT('.')) == NULL ) str << wxT(".ini"); #endif @@ -551,7 +475,7 @@ wxFileConfig::wxFileConfig(wxInputStream &inStream) while ( !inStream.Read(buf, WXSIZEOF(buf)).Eof() ) strTmp.append(wxConvertMB2WX(buf), inStream.LastRead()); - strTmp += wxString(buf, inStream.LastRead()); + strTmp.append(wxConvertMB2WX(buf), inStream.LastRead()); strTrans = wxTextBuffer::Translate(strTmp); } @@ -895,8 +819,7 @@ bool wxFileConfig::HasEntry(const wxString& strName) const // read/write values // ---------------------------------------------------------------------------- -bool wxFileConfig::Read(const wxString& key, - wxString* pStr) const +bool wxFileConfig::DoReadString(const wxString& key, wxString* pStr) const { wxConfigPathChanger path(this, key); @@ -905,32 +828,12 @@ bool wxFileConfig::Read(const wxString& key, return FALSE; } - *pStr = ExpandEnvVars(pEntry->Value()); - return TRUE; -} - -bool wxFileConfig::Read(const wxString& key, - wxString* pStr, const wxString& defVal) const -{ - wxConfigPathChanger path(this, key); + *pStr = pEntry->Value(); - wxFileConfigEntry *pEntry = m_pCurrentGroup->FindEntry(path.Name()); - bool ok; - if (pEntry == NULL) { - if( IsRecordingDefaults() ) - ((wxFileConfig *)this)->Write(key,defVal); - *pStr = ExpandEnvVars(defVal); - ok = FALSE; - } - else { - *pStr = ExpandEnvVars(pEntry->Value()); - ok = TRUE; - } - - return ok; + return TRUE; } -bool wxFileConfig::Read(const wxString& key, long *pl) const +bool wxFileConfig::DoReadLong(const wxString& key, long *pl) const { wxString str; if ( !Read(key, & str) ) @@ -938,11 +841,10 @@ bool wxFileConfig::Read(const wxString& key, long *pl) const return FALSE; } - *pl = wxAtol(str); - return TRUE; + return str.ToLong(pl); } -bool wxFileConfig::Write(const wxString& key, const wxString& szValue) +bool wxFileConfig::DoWriteString(const wxString& key, const wxString& szValue) { wxConfigPathChanger path(this, key); @@ -977,12 +879,9 @@ bool wxFileConfig::Write(const wxString& key, const wxString& szValue) return TRUE; } -bool wxFileConfig::Write(const wxString& key, long lValue) +bool wxFileConfig::DoWriteLong(const wxString& key, long lValue) { - // ltoa() is not ANSI :-( - wxString buf; - buf.Printf(wxT("%ld"), lValue); - return Write(key, buf); + return Write(key, wxString::Format(_T("%ld"), lValue)); } bool wxFileConfig::Flush(bool /* bCurrentOnly */)