From 0b8f7439cb27bbc88f94dd18d4d1069d8d1f48a2 Mon Sep 17 00:00:00 2001 From: tmator Date: Thu, 26 Feb 2009 07:24:50 +0000 Subject: fix plugin dir on osx git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2443 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/FileUtil.cpp | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'Source/Core/Common/Src/FileUtil.cpp') 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 #endif +#if defined(__APPLE__) + +#include +#include +#include +#include + +#endif + #include #include @@ -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)) -- cgit v1.2.3