VCMIDirs.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __VCMIDIRS_H__
  2. #define __VCMIDIRS_H__
  3. /*
  4. * UserHome.h, part of VCMI engine
  5. *
  6. * Authors: listed in file AUTHORS in main folder
  7. *
  8. * License: GNU General Public License v2.0 or later
  9. * Full text of license available in license.txt file, in main folder
  10. *
  11. */
  12. #ifndef _WIN32 //we need boost here only on non-win platforms
  13. #include <boost/filesystem.hpp>
  14. using namespace boost::filesystem;
  15. #endif
  16. /// Where to find the various VCMI files. This is mostly useful for linux.
  17. class VCMIDirs {
  18. public:
  19. std::string UserPath;
  20. VCMIDirs()
  21. {
  22. #ifdef _WIN32
  23. UserPath = DATA_DIR;
  24. #else
  25. try {
  26. #ifdef ANDROID
  27. UserPath = DATA_DIR;
  28. #else
  29. // Find vcmi user directory and create it if necessary
  30. std::string home_dir = ".";
  31. if( getenv("HOME") != NULL )
  32. home_dir = getenv("HOME");
  33. UserPath = path(home_dir + "/.vcmi").string();
  34. #endif
  35. create_directory(UserPath);
  36. create_directory(UserPath + "/config");
  37. create_directory(UserPath + "/Games");
  38. /* Home directory can contain some extra maps. */
  39. create_directory(UserPath + "/Maps");
  40. }
  41. catch(const std::exception & e)
  42. {
  43. }
  44. #endif
  45. }
  46. };
  47. extern VCMIDirs GVCMIDirs;
  48. #endif // __VCMIDIRS_H__