Merge branch 'movement' of git://github.com/zinnschlag/openmw.git into collisions
commit
d1bcfcb94d
@ -0,0 +1,56 @@
|
||||
#include "path.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
||||
#include <stdlib.h> //getenv
|
||||
#endif
|
||||
|
||||
|
||||
std::string OMW::Path::getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile)
|
||||
{
|
||||
std::string theBasePath;
|
||||
if(parType == GLOBAL_CFG_PATH)
|
||||
{
|
||||
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||
theBasePath = macBundlePath() + "/Contents/MacOS/"; //FIXME do we have global/local with OSX?
|
||||
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
||||
theBasePath = "/etc/"+parApp+"/";
|
||||
#else
|
||||
theBasePath = "";
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||
theBasePath = macBundlePath() + "/Contents/MacOS/"; //FIXME do we have global/local with OSX?
|
||||
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
||||
const char* theDir;
|
||||
if ((theDir = getenv("OPENMW_HOME")) != NULL)
|
||||
{
|
||||
theBasePath = std::string(theDir)+"/";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((theDir = getenv("XDG_CONFIG_HOME")))
|
||||
{
|
||||
theBasePath = std::string(theDir)+"/"+parApp+"/";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((theDir = getenv("HOME")) == NULL)
|
||||
return parFile;
|
||||
theBasePath = std::string(theDir)+"/.config/"+parApp+"/";
|
||||
}
|
||||
}
|
||||
boost::filesystem::create_directories(boost::filesystem::path(theBasePath));
|
||||
#else
|
||||
theBasePath = "";
|
||||
#endif
|
||||
}
|
||||
|
||||
theBasePath.append(parFile);
|
||||
return theBasePath;
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
#ifndef PATH__HPP
|
||||
#define PATH__HPP
|
||||
|
||||
#include <OgrePlatform.h>
|
||||
#include <string>
|
||||
|
||||
namespace OMW
|
||||
{
|
||||
class Path
|
||||
{
|
||||
public:
|
||||
enum PathTypeEnum
|
||||
{
|
||||
USER_CFG_PATH,
|
||||
GLOBAL_CFG_PATH
|
||||
};
|
||||
|
||||
static std::string getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile);
|
||||
};
|
||||
}
|
||||
#endif
|
@ -1,2 +1,3 @@
|
||||
data=${MORROWIND_DATA_FILES}
|
||||
resources=${MORROWIND_RESOURCE_FILES}
|
||||
|
||||
|
Loading…
Reference in New Issue