summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authortmator <tmator@gmail.com>2009-02-26 07:24:50 +0000
committertmator <tmator@gmail.com>2009-02-26 07:24:50 +0000
commit0b8f7439cb27bbc88f94dd18d4d1069d8d1f48a2 (patch)
tree8cc6dffb6b46d400f614fb086bf0ecd3e3541447 /Source/Core
parent491e24792a233d813f702d885ab43b72b76997e6 (diff)
fix plugin dir on osx
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2443 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp57
-rw-r--r--Source/Core/Common/Src/FileUtil.h4
-rw-r--r--Source/Core/Core/Src/ConfigManager.cpp30
-rw-r--r--Source/Core/Core/Src/PluginManager.cpp7
4 files changed, 71 insertions, 27 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index e649dfaaf9..e75ec1ee0c 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -32,6 +32,15 @@
#include <stdlib.h>
#endif
+#if defined(__APPLE__)
+
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFUrl.h>
+#include <CoreFoundation/CFBundle.h>
+#include <sys/param.h>
+
+#endif
+
#include <fstream>
#include <sys/stat.h>
@@ -287,6 +296,54 @@ std::string GetUserDirectory()
return std::string(path);
}
+
+//osx specific functions
+#if defined(__APPLE__)
+
+std::string GetBundleDirectory()
+{
+
+ // Plugin path will be Dolphin.app/Contents/PlugIns
+ CFURLRef BundleRef;
+ char AppBundlePath[MAXPATHLEN];
+
+ // Get the main bundle for the app
+ BundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+
+ CFStringRef BundlePath = CFURLCopyFileSystemPath(BundleRef, kCFURLPOSIXPathStyle);
+ CFStringGetFileSystemRepresentation(BundlePath, AppBundlePath, sizeof(AppBundlePath));
+
+ CFRelease(BundleRef);
+ CFRelease(BundlePath);
+
+ return AppBundlePath;
+
+
+}
+std::string GetPluginsDirectory()
+{
+
+ CFURLRef PluginDirRef;
+ char PluginPath[MAXPATHLEN];
+
+ PluginDirRef = CFBundleCopyBuiltInPlugInsURL(CFBundleGetMainBundle());
+
+ CFStringRef PluginDirPath = CFURLCopyFileSystemPath(PluginDirRef, kCFURLPOSIXPathStyle);
+ CFStringGetFileSystemRepresentation(PluginDirPath, PluginPath, sizeof(PluginPath));
+
+ CFRelease(PluginDirRef);
+ CFRelease(PluginDirPath);
+
+ std::string PluginsDir = GetBundleDirectory();
+ PluginsDir += DIR_SEP;
+ PluginsDir += PluginPath;
+
+ return PluginsDir;
+
+}
+
+
+#endif
u64 GetSize(const char *filename)
{
if (!Exists(filename))
diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h
index 5befbb7b46..f88d46808f 100644
--- a/Source/Core/Common/Src/FileUtil.h
+++ b/Source/Core/Common/Src/FileUtil.h
@@ -55,6 +55,10 @@ bool DeleteDirRecursively(const std::string& _Directory);
void GetCurrentDirectory(std::string& _rDirectory);
bool SetCurrentDirectory(const std::string& _rDirectory);
+#if defined(__APPLE__)
+std::string GetPluginsDirectory();
+#endif
+
} // namespace
#endif
diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp
index 4a966dd863..8f63c08f26 100644
--- a/Source/Core/Core/Src/ConfigManager.cpp
+++ b/Source/Core/Core/Src/ConfigManager.cpp
@@ -20,14 +20,10 @@
#include "Common.h"
#include "IniFile.h"
#include "ConfigManager.h"
-#ifdef __APPLE__
-#include <CoreFoundation/CFString.h>
-#include <CoreFoundation/CFUrl.h>
-#include <CoreFoundation/CFBundle.h>
-#include <sys/param.h>
+#if defined(__APPLE__)
+#include "FileUtil.h"
#endif
-
SConfig SConfig::m_Instance;
@@ -123,26 +119,8 @@ void SConfig::LoadSettings()
{
IniFile ini;
ini.Load(CONFIG_FILE);
-#ifdef __APPLE__
- // Plugin path will be Dolphin.app/Contents/PlugIns
- CFURLRef BundleRef, PluginDirRef;
- // Get the main bundle for the app
- BundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
- PluginDirRef = CFBundleCopyBuiltInPlugInsURL(CFBundleGetMainBundle());
- CFStringRef BundlePath = CFURLCopyFileSystemPath(BundleRef, kCFURLPOSIXPathStyle);
- CFStringRef PluginDirPath = CFURLCopyFileSystemPath(PluginDirRef, kCFURLPOSIXPathStyle);
- char AppBundlePath[MAXPATHLEN], PluginPath[MAXPATHLEN];
- CFStringGetFileSystemRepresentation(BundlePath, AppBundlePath, sizeof(AppBundlePath));
- CFStringGetFileSystemRepresentation(PluginDirPath, PluginPath, sizeof(PluginPath));
-// printf("bundle path = %s %s\n", AppBundlePath, PluginPath);
- CFRelease(BundleRef);
- CFRelease(BundlePath);
- CFRelease(PluginDirRef);
- CFRelease(PluginDirPath);
- std::string PluginsDir = AppBundlePath;
- PluginsDir += DIR_SEP;
- PluginsDir += PluginPath;
- PluginsDir += DIR_SEP;
+#if defined(__APPLE__)
+ std::string PluginsDir = File::GetPluginsDirectory();
m_DefaultGFXPlugin = PluginsDir + DEFAULT_GFX_PLUGIN;
m_DefaultDSPPlugin = PluginsDir + DEFAULT_DSP_PLUGIN;
diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp
index 846cec1fc7..d852c0eadc 100644
--- a/Source/Core/Core/Src/PluginManager.cpp
+++ b/Source/Core/Core/Src/PluginManager.cpp
@@ -365,7 +365,12 @@ void CPluginManager::ScanForPlugins()
m_PluginInfos.clear();
// Get plugins dir
CFileSearch::XStringVector Directories;
- Directories.push_back(std::string(PLUGINS_DIR));
+
+ #if defined(__APPLE__)
+ Directories.push_back(File::GetPluginsDirectory());
+ #else
+ Directories.push_back(std::string(PLUGINS_DIR));
+ #endif
CFileSearch::XStringVector Extensions;
Extensions.push_back("*" PLUGIN_SUFFIX);