X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7beba2fc73283f5b750227459da57e66bcd475f5..270a909e20a2c652fd816ad14407113ad0319c9d:/src/common/fileconf.cpp diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index d26dd662c7..54bc21641a 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -98,7 +98,9 @@ wxString wxFileConfig::GetGlobalDir() { wxString strDir; - #ifdef __UNIX__ + #ifdef __VMS__ // Note if __VMS is defined __UNIX is also defined + strDir = wxT("sys$manager:"); + #elif defined( __UNIX__ ) strDir = wxT("/etc/"); #elif defined(__WXPM__) ULONG aulSysInfo[QSV_MAX] = {0}; @@ -194,7 +196,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,13 +224,20 @@ wxString wxFileConfig::GetLocalDir() { wxString strDir; +#ifndef __WXMAC__ wxGetHomeDir(&strDir); -#ifdef __UNIX__ +#ifndef __VMS__ +# ifdef __UNIX__ if (strDir.Last() != wxT('/')) strDir << wxT('/'); #else if (strDir.Last() != wxT('\\')) strDir << wxT('\\'); #endif +#endif +#else + // no local dir concept on mac + return GetGlobalDir() ; +#endif return strDir; } @@ -229,6 +250,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 @@ -238,8 +261,14 @@ wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile) wxString wxFileConfig::GetLocalFileName(const wxChar *szFile) { - wxString str = GetLocalDir(); - +#ifdef __VMS__ // On VMS I saw the problem that the home directory was appended + // twice for the configuration file. Does that also happen for other + // platforms? + wxString str = wxT( ' ' ); +#else + wxString str = GetLocalDir(); +#endif + #ifdef __UNIX__ str << wxT('.'); #endif @@ -251,6 +280,10 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile) str << wxT(".ini"); #endif + + #ifdef __WXMAC__ + str << " Preferences"; + #endif return str; } @@ -749,7 +782,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 } // ----------------------------------------------------------------------------