2011-12-14 00:23:17 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GameConstants.h"
|
2011-06-15 05:15:05 +03:00
|
|
|
|
2009-10-10 18:09:02 +03:00
|
|
|
/*
|
2011-12-14 00:23:17 +03:00
|
|
|
* VCMIDirs.h, part of VCMI engine
|
2009-10-10 18:09:02 +03:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-11-13 18:02:25 +02:00
|
|
|
#ifndef _WIN32 //we need boost here only on non-win platforms
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
using namespace boost::filesystem;
|
|
|
|
#endif
|
2009-10-10 18:09:02 +03:00
|
|
|
|
2011-06-15 05:15:05 +03:00
|
|
|
/// Where to find the various VCMI files. This is mostly useful for linux.
|
2009-10-10 18:09:02 +03:00
|
|
|
class VCMIDirs {
|
|
|
|
public:
|
|
|
|
std::string UserPath;
|
|
|
|
|
|
|
|
VCMIDirs()
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
2011-12-14 00:23:17 +03:00
|
|
|
UserPath = GameConstants::DATA_DIR;
|
2009-10-10 18:09:02 +03:00
|
|
|
#else
|
2011-06-15 05:15:05 +03:00
|
|
|
try {
|
|
|
|
#ifdef ANDROID
|
|
|
|
UserPath = DATA_DIR;
|
2013-02-05 02:12:43 +03:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
// This is Cocoa code that should be normally used to get path to Application Support folder but can't use it here for now...
|
|
|
|
// NSArray* urls = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
|
|
|
|
// UserPath = path([urls[0] path] + "/vcmi").string();
|
|
|
|
|
|
|
|
// ...so here goes a bit of hardcode instead
|
|
|
|
std::string home_dir = ".";
|
|
|
|
if (getenv("HOME") != NULL )
|
|
|
|
home_dir = getenv("HOME");
|
|
|
|
|
|
|
|
UserPath = path(home_dir + "/Library/Application Support/vcmi").string();
|
2011-06-15 05:15:05 +03:00
|
|
|
#else
|
|
|
|
// Find vcmi user directory and create it if necessary
|
|
|
|
std::string home_dir = ".";
|
2013-02-05 02:12:43 +03:00
|
|
|
if (getenv("HOME") != NULL )
|
2011-06-15 05:15:05 +03:00
|
|
|
home_dir = getenv("HOME");
|
2009-10-10 18:09:02 +03:00
|
|
|
|
2011-06-15 05:15:05 +03:00
|
|
|
UserPath = path(home_dir + "/.vcmi").string();
|
|
|
|
#endif
|
|
|
|
create_directory(UserPath);
|
|
|
|
create_directory(UserPath + "/config");
|
|
|
|
create_directory(UserPath + "/Games");
|
2011-09-25 18:41:03 +03:00
|
|
|
|
|
|
|
/* Home directory can contain some extra maps. */
|
|
|
|
create_directory(UserPath + "/Maps");
|
2011-06-15 05:15:05 +03:00
|
|
|
}
|
|
|
|
catch(const std::exception & e)
|
|
|
|
{
|
|
|
|
}
|
2009-10-10 18:09:02 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
2012-05-25 17:53:56 +03:00
|
|
|
|
|
|
|
extern DLL_LINKAGE VCMIDirs GVCMIDirs;
|