X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/223d09f6b523aac674ef9b72a883dfa8d37c5d4e..6842d18650b487249b4ae29d0d7e17231b24cde8:/src/common/fileconf.cpp diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 6b33a83545..80b528c70e 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -194,7 +194,19 @@ wxString wxFileConfig::GetGlobalDir() #elif defined(__WXSTUBS__) wxASSERT_MSG( FALSE, wxT("TODO") ) ; #elif defined(__WXMAC__) - wxASSERT_MSG( FALSE, wxT("TODO") ) ; + { + short vRefNum ; + long dirID ; + + if ( FindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &vRefNum, &dirID) == noErr) + { + FSSpec file ; + if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr ) + { + strDir = wxMacFSSpec2UnixFilename( &file ) + "/" ; + } + } + } #else // Windows wxChar szWinDir[MAX_PATH]; ::GetWindowsDirectory(szWinDir, MAX_PATH); @@ -210,6 +222,7 @@ wxString wxFileConfig::GetLocalDir() { wxString strDir; +#ifndef __WXMAC__ wxGetHomeDir(&strDir); #ifdef __UNIX__ @@ -217,6 +230,10 @@ wxString wxFileConfig::GetLocalDir() #else if (strDir.Last() != wxT('\\')) strDir << wxT('\\'); #endif +#else + // no local dir concept on mac + return GetGlobalDir() ; +#endif return strDir; } @@ -229,6 +246,8 @@ wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile) if ( wxStrchr(szFile, wxT('.')) == NULL ) #ifdef __UNIX__ str << wxT(".conf"); + #elif defined( __WXMAC__ ) + str << " Preferences"; #else // Windows str << wxT(".ini"); #endif // UNIX/Win @@ -251,6 +270,10 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile) str << wxT(".ini"); #endif + + #ifdef __WXMAC__ + str << " Preferences"; + #endif return str; } @@ -324,20 +347,21 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName, // if the path is not absolute, prepend the standard directory to it // UNLESS wxCONFIG_USE_RELATIVE_PATH style is set - if ( !(style & wxCONFIG_USE_RELATIVE_PATH) ){ - if ( !m_strLocalFile.IsEmpty() && !wxIsAbsolutePath(m_strLocalFile) ) - { - wxString strLocal = m_strLocalFile; - m_strLocalFile = GetLocalDir(); - m_strLocalFile << strLocal; - } - - if ( !m_strGlobalFile.IsEmpty() && !wxIsAbsolutePath(m_strGlobalFile) ) - { - wxString strGlobal = m_strGlobalFile; - m_strGlobalFile = GetGlobalDir(); - m_strGlobalFile << strGlobal; - } + if ( !(style & wxCONFIG_USE_RELATIVE_PATH) ) + { + if ( !m_strLocalFile.IsEmpty() && !wxIsAbsolutePath(m_strLocalFile) ) + { + wxString strLocal = m_strLocalFile; + m_strLocalFile = GetLocalDir(); + m_strLocalFile << strLocal; + } + + if ( !m_strGlobalFile.IsEmpty() && !wxIsAbsolutePath(m_strGlobalFile) ) + { + wxString strGlobal = m_strGlobalFile; + m_strGlobalFile = GetGlobalDir(); + m_strGlobalFile << strGlobal; + } } Init(); @@ -748,7 +772,25 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */) } } +#ifndef __WXMAC__ return file.Commit(); +#else + bool ret = file.Commit(); + if ( ret ) + { + FSSpec spec ; + + wxUnixFilename2FSSpec( m_strLocalFile , &spec ) ; + FInfo finfo ; + if ( FSpGetFInfo( &spec , &finfo ) == noErr ) + { + finfo.fdType = 'TEXT' ; + finfo.fdCreator = 'ttxt' ; + FSpSetFInfo( &spec , &finfo ) ; + } + } + return ret ; +#endif } // ----------------------------------------------------------------------------