mirror of
https://github.com/vcmi/vcmi.git
synced 2026-06-19 22:57:37 +02:00
VCMIDirs: add hack to run from single directory on Mac and Linux
Also change working directory to where binary is on all platforms except Android
This commit is contained in:
+3
-4
@@ -232,11 +232,10 @@ int main(int argc, char * argv[])
|
|||||||
// boost will crash without this
|
// boost will crash without this
|
||||||
setenv("LANG", "C", 1);
|
setenv("LANG", "C", 1);
|
||||||
#endif
|
#endif
|
||||||
#ifdef VCMI_APPLE
|
|
||||||
|
#ifndef VCMI_ANDROID
|
||||||
// Correct working dir executable folder (not bundle folder) so we can use executable relative paths
|
// Correct working dir executable folder (not bundle folder) so we can use executable relative paths
|
||||||
std::string executablePath = argv[0];
|
boost::filesystem::current_path(boost::filesystem::system_complete(argv[0]).parent_path());
|
||||||
std::string workDir = executablePath.substr(0, executablePath.rfind('/'));
|
|
||||||
chdir(workDir.c_str());
|
|
||||||
#endif
|
#endif
|
||||||
std::cout << "Starting... " << std::endl;
|
std::cout << "Starting... " << std::endl;
|
||||||
po::options_description opts("Allowed options");
|
po::options_description opts("Allowed options");
|
||||||
|
|||||||
+18
-2
@@ -452,7 +452,17 @@ bfs::path VCMIDirsOSX::userConfigPath() const { return userDataPath() / "config"
|
|||||||
|
|
||||||
std::vector<bfs::path> VCMIDirsOSX::dataPaths() const
|
std::vector<bfs::path> VCMIDirsOSX::dataPaths() const
|
||||||
{
|
{
|
||||||
return std::vector<bfs::path>(1, "../Resources/Data");
|
std::vector<bfs::path> ret;
|
||||||
|
//FIXME: need some proper codepath for detecting running from build output directory
|
||||||
|
if(bfs::exists("config") && bfs::exists("Mods") && bfs::exists("vcmiserver"))
|
||||||
|
{
|
||||||
|
ret.push_back(".");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret.push_back("../Resources/Data");
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bfs::path VCMIDirsOSX::libraryPath() const { return "."; }
|
bfs::path VCMIDirsOSX::libraryPath() const { return "."; }
|
||||||
@@ -521,7 +531,13 @@ std::vector<bfs::path> VCMIDirsXDG::dataPaths() const
|
|||||||
const char* tempResult;
|
const char* tempResult;
|
||||||
ret.push_back(M_DATA_DIR);
|
ret.push_back(M_DATA_DIR);
|
||||||
|
|
||||||
if ((tempResult = getenv("XDG_DATA_DIRS")) != nullptr)
|
//FIXME: need some proper codepath for detecting running from build output directory
|
||||||
|
if(bfs::exists("config") && bfs::exists("Mods") && bfs::exists("vcmiserver"))
|
||||||
|
{
|
||||||
|
//For now we'll disable usage of system directories when VCMI running from bin directory
|
||||||
|
ret.push_back(".");
|
||||||
|
}
|
||||||
|
else if((tempResult = getenv("XDG_DATA_DIRS")) != nullptr)
|
||||||
{
|
{
|
||||||
std::string dataDirsEnv = tempResult;
|
std::string dataDirsEnv = tempResult;
|
||||||
std::vector<std::string> dataDirs;
|
std::vector<std::string> dataDirs;
|
||||||
|
|||||||
@@ -609,7 +609,7 @@ void handleLinuxSignal(int sig)
|
|||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
#ifdef VCMI_APPLE
|
#ifndef VCMI_WINDOWS
|
||||||
// Correct working dir executable folder (not bundle folder) so we can use executable relative paths
|
// Correct working dir executable folder (not bundle folder) so we can use executable relative paths
|
||||||
std::string executablePath = argv[0];
|
std::string executablePath = argv[0];
|
||||||
std::string workDir = executablePath.substr(0, executablePath.rfind('/'));
|
std::string workDir = executablePath.substr(0, executablePath.rfind('/'));
|
||||||
|
|||||||
Reference in New Issue
Block a user