]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/corefoundation/stdpaths_cf.cpp
corrected GetKeyInfo() (bug 1815516)
[wxWidgets.git] / src / mac / corefoundation / stdpaths_cf.cpp
index 62725328e3d8d0e55aa5f960b608a345ed41c10b..f8cf48355a0e118d378c02458134914f4698ab48 100644 (file)
@@ -27,6 +27,9 @@
 
 #include "wx/stdpaths.h"
 #include "wx/filename.h"
+#ifdef __WXMAC__
+#include "wx/mac/private.h"
+#endif
 #include "wx/mac/corefoundation/cfstring.h"
 
 #if defined(__DARWIN__)
@@ -103,20 +106,44 @@ wxString wxStandardPathsCF::GetFromFunc(wxCFURLRef (*func)(wxCFBundleRef)) const
     return ret;
 }
 
+wxString wxStandardPathsCF::GetDocumentsDir() const
+{
+#ifdef __WXMAC__
+    return wxMacFindFolderNoSeparator
+        (
+#if TARGET_API_MAC_OSX
+        kUserDomain,
+#else
+        kOnSystemDisk,
+#endif
+        kDocumentsFolderType,
+        kCreateFolder
+        );
+#else
+    return wxFileName::GetHomeDir() + wxT("/Documents");
+#endif
+}
+
 // ----------------------------------------------------------------------------
 // wxStandardPathsCF public API
 // ----------------------------------------------------------------------------
 
 wxString wxStandardPathsCF::GetConfigDir() const
 {
-    // TODO: What do we do for pure Carbon?
+#ifdef __WXMAC__
+    return wxMacFindFolder((short)kLocalDomain, kPreferencesFolderType, kCreateFolder);
+#else
     return wxT("/Library/Preferences");
+#endif
 }
 
 wxString wxStandardPathsCF::GetUserConfigDir() const
 {
-    // TODO: What do we do for pure Carbon?
+#ifdef __WXMAC__
+    return wxMacFindFolder((short)kUserDomain, kPreferencesFolderType, kCreateFolder);
+#else
     return wxFileName::GetHomeDir() + wxT("/Library/Preferences");
+#endif
 }
 
 wxString wxStandardPathsCF::GetDataDir() const
@@ -124,14 +151,43 @@ wxString wxStandardPathsCF::GetDataDir() const
     return GetFromFunc(CFBundleCopySharedSupportURL);
 }
 
+// TODO: implement this using real CoreFoundation API instead of Carbon API
+wxString wxStandardPathsCF::GetExecutablePath() const
+{
+#ifdef __WXMAC__
+    ProcessInfoRec processinfo;
+    ProcessSerialNumber procno ;
+    FSSpec fsSpec;
+
+    procno.highLongOfPSN = 0 ;
+    procno.lowLongOfPSN = kCurrentProcess ;
+    processinfo.processInfoLength = sizeof(ProcessInfoRec);
+    processinfo.processName = NULL;
+    processinfo.processAppSpec = &fsSpec;
+
+    GetProcessInformation( &procno , &processinfo ) ;
+    return wxMacFSSpec2MacFilename(&fsSpec);
+#else
+    return wxStandardPathsBase::GetExecutablePath();
+#endif
+}
+
 wxString wxStandardPathsCF::GetLocalDataDir() const
 {
+#ifdef __WXMAC__
+    return AppendAppName(wxMacFindFolder((short)kLocalDomain, kApplicationSupportFolderType, kCreateFolder));
+#else
     return AppendAppName(wxT("/Library/Application Support"));
+#endif
 }
 
 wxString wxStandardPathsCF::GetUserDataDir() const
 {
+#ifdef __WXMAC__
+    return AppendAppName(wxMacFindFolder((short)kUserDomain, kApplicationSupportFolderType, kCreateFolder));
+#else
     return AppendAppName(wxFileName::GetHomeDir() + _T("/Library/Application Support"));
+#endif
 }
 
 wxString wxStandardPathsCF::GetPluginsDir() const
@@ -145,7 +201,7 @@ wxString wxStandardPathsCF::GetResourcesDir() const
 }
 
 wxString
-wxStandardPathsCF::GetLocalizedResourcesDir(const wxChar *lang,
+wxStandardPathsCF::GetLocalizedResourcesDir(const wxString& lang,
                                             ResourceCat category) const
 {
     return wxStandardPathsBase::