mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
fix compile on osx and linux
added GetPluginDirectory (please check on windows) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2490 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -27,7 +27,8 @@
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
#if defined __APPLE__
|
#if defined __APPLE__
|
||||||
char* strndup (char const *s, size_t n);
|
char* strndup (char const *s, size_t n);
|
||||||
|
size_t strnlen(const char *s, size_t n);
|
||||||
#else
|
#else
|
||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
#endif // APPLE
|
#endif // APPLE
|
||||||
|
@ -32,6 +32,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <CoreFoundation/CFString.h>
|
||||||
|
#include <CoreFoundation/CFUrl.h>
|
||||||
|
#include <CoreFoundation/CFBundle.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
@ -305,30 +312,6 @@ bool Copy(const char *srcFilename, const char *destFilename)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a pointer to a string with a Dolphin data dir in the user's home directory.
|
|
||||||
// To be used in "multi-user" mode (that is, installed).
|
|
||||||
const char *GetUserDirectory()
|
|
||||||
{
|
|
||||||
// Make sure we only need to do it once
|
|
||||||
static char path[MAX_PATH] = {0};
|
|
||||||
if (strlen(path) > 0)
|
|
||||||
return path;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
char homedir[MAX_PATH];
|
|
||||||
if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path)))
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
char *homedir = getenv("HOME");
|
|
||||||
if (!homedir)
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s" DIR_SEP DOLPHIN_DATA_DIR, homedir);
|
|
||||||
INFO_LOG(COMMON, "GetUserDirectory: Setting to %s:", path);
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the size of filename (64bit)
|
// Returns the size of filename (64bit)
|
||||||
u64 GetSize(const char *filename)
|
u64 GetSize(const char *filename)
|
||||||
{
|
{
|
||||||
@ -520,5 +503,87 @@ bool SetCurrentDirectory(const char *_rDirectory)
|
|||||||
return chdir(_rDirectory) == 0;
|
return chdir(_rDirectory) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Returns the path to where the plugins are
|
||||||
|
std::string GetPluginsDirectory()
|
||||||
|
{
|
||||||
|
std::string pluginsDir;
|
||||||
|
|
||||||
|
#if defined (__APPLE__)
|
||||||
|
PluginsDir = GetBundleDirectory();
|
||||||
|
PluginsDir += DIR_SEP;
|
||||||
|
PluginsDir += PLUGINS_DIR;
|
||||||
|
#elsif __linux__
|
||||||
|
pluginsDir = PLUGINS_DIR;
|
||||||
|
// FIXME global install
|
||||||
|
#else
|
||||||
|
pluginsDir = PLUGINS_DIR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
INFO_LOG(COMMON, "GetPluginsDirectory: Setting to %s:", pluginsDir.c_str());
|
||||||
|
return pluginsDir;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the path to where the sys file are
|
||||||
|
std::string GetSysDirectory()
|
||||||
|
{
|
||||||
|
std::string sysDir;
|
||||||
|
|
||||||
|
#if defined (__APPLE__)
|
||||||
|
sysDir = GetBundleDirectory();
|
||||||
|
sysDir += DIR_SEP;
|
||||||
|
sysDir += SYSDATA_DIR;
|
||||||
|
#elsif __linux__
|
||||||
|
sysDir = SYSDATA_DIR;
|
||||||
|
// FIXME global install
|
||||||
|
#else
|
||||||
|
sysDir = SYSDATA_DIR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
INFO_LOG(COMMON, "GetSysDirectory: Setting to %s:", sysDir.c_str());
|
||||||
|
return sysDir;
|
||||||
|
|
||||||
|
}
|
||||||
|
// Returns a pointer to a string with a Dolphin data dir in the user's home
|
||||||
|
// directory. To be used in "multi-user" mode (that is, installed).
|
||||||
|
const char *GetUserDirectory()
|
||||||
|
{
|
||||||
|
// Make sure we only need to do it once
|
||||||
|
static char path[MAX_PATH] = {0};
|
||||||
|
if (strlen(path) > 0)
|
||||||
|
return path;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
char homedir[MAX_PATH];
|
||||||
|
if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path)))
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
char *homedir = getenv("HOME");
|
||||||
|
if (!homedir)
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
snprintf(path, sizeof(path), "%s" DIR_SEP DOLPHIN_DATA_DIR, homedir);
|
||||||
|
INFO_LOG(COMMON, "GetUserDirectory: Setting to %s:", path);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -84,9 +84,21 @@ const char *GetCurrentDirectory();
|
|||||||
// Set the current directory to given directory
|
// Set the current directory to given directory
|
||||||
bool SetCurrentDirectory(const char *directory);
|
bool SetCurrentDirectory(const char *directory);
|
||||||
|
|
||||||
// Returns a pointer to a string with the dolphin data dir
|
|
||||||
|
// Returns a pointer to a string with a Dolphin data dir in the user's home
|
||||||
|
// directory. To be used in "multi-user" mode (that is, installed).
|
||||||
const char *GetUserDirectory();
|
const char *GetUserDirectory();
|
||||||
|
|
||||||
|
// Returns the path to where the plugins are
|
||||||
|
std::string GetPluginsDirectory();
|
||||||
|
|
||||||
|
// Returns the path to where the sys file are
|
||||||
|
std::string GetSysDirectory();
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
std::string GetBundleDirectory();
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,14 +37,24 @@ const char *GetLastErrorMsg()
|
|||||||
return errStr;
|
return errStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strndup (char const *s, size_t n)
|
#ifdef __APPLE__
|
||||||
|
// strlen with cropping after size n
|
||||||
|
size_t strnlen(const char *s, size_t n)
|
||||||
|
{
|
||||||
|
const char *p = (const char *)memchr(s, 0, n);
|
||||||
|
return(p ? p-s : n);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// strdup with cropping after size n
|
||||||
|
char* strndup(char const *s, size_t n)
|
||||||
{
|
{
|
||||||
size_t len = strnlen(s, n);
|
size_t len = strnlen(s, n);
|
||||||
char *dup = (char *)malloc(len + 1);
|
char *dup = (char *)malloc(len + 1);
|
||||||
|
|
||||||
if (dup == NULL)
|
if (dup == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dup[len] = '\0';
|
dup[len] = '\0';
|
||||||
return (char *)memcpy(dup, s, len);
|
return (char *)memcpy(dup, s, len);
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,8 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include "ConfigManager.h"
|
#include "ConfigManager.h"
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
#endif
|
|
||||||
SConfig SConfig::m_Instance;
|
SConfig SConfig::m_Instance;
|
||||||
|
|
||||||
|
|
||||||
@ -119,23 +117,14 @@ void SConfig::LoadSettings()
|
|||||||
{
|
{
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
ini.Load(CONFIG_FILE);
|
ini.Load(CONFIG_FILE);
|
||||||
#if defined(__APPLE__)
|
|
||||||
std::string PluginsDir = File::GetPluginsDirectory();
|
std::string PluginsDir = File::GetPluginsDirectory();
|
||||||
|
|
||||||
|
// Hard coded default
|
||||||
m_DefaultGFXPlugin = PluginsDir + DEFAULT_GFX_PLUGIN;
|
m_DefaultGFXPlugin = PluginsDir + DEFAULT_GFX_PLUGIN;
|
||||||
m_DefaultDSPPlugin = PluginsDir + DEFAULT_DSP_PLUGIN;
|
m_DefaultDSPPlugin = PluginsDir + DEFAULT_DSP_PLUGIN;
|
||||||
m_DefaultPADPlugin = PluginsDir + DEFAULT_PAD_PLUGIN;
|
m_DefaultPADPlugin = PluginsDir + DEFAULT_PAD_PLUGIN;
|
||||||
m_DefaultWiiMotePlugin = PluginsDir + DEFAULT_WIIMOTE_PLUGIN;
|
m_DefaultWiiMotePlugin = PluginsDir + DEFAULT_WIIMOTE_PLUGIN;
|
||||||
|
|
||||||
#else
|
|
||||||
// Hard coded default plugin
|
|
||||||
{
|
|
||||||
m_DefaultGFXPlugin = PLUGINS_DIR DIR_SEP DEFAULT_GFX_PLUGIN;
|
|
||||||
m_DefaultDSPPlugin = PLUGINS_DIR DIR_SEP DEFAULT_DSP_PLUGIN;
|
|
||||||
m_DefaultPADPlugin = PLUGINS_DIR DIR_SEP DEFAULT_PAD_PLUGIN;
|
|
||||||
m_DefaultWiiMotePlugin = PLUGINS_DIR DIR_SEP DEFAULT_WIIMOTE_PLUGIN;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// General
|
// General
|
||||||
{
|
{
|
||||||
ini.Get("General", "LastFilename", &m_LastFilename);
|
ini.Get("General", "LastFilename", &m_LastFilename);
|
||||||
|
@ -23,7 +23,6 @@ files = [
|
|||||||
'VertexManager.cpp',
|
'VertexManager.cpp',
|
||||||
'VertexLoaderManager.cpp',
|
'VertexLoaderManager.cpp',
|
||||||
'XFB.cpp',
|
'XFB.cpp',
|
||||||
'XFStructs.cpp',
|
|
||||||
'TextureConversionShader.cpp',
|
'TextureConversionShader.cpp',
|
||||||
'OnScreenDisplay.cpp',
|
'OnScreenDisplay.cpp',
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user