Advertisement
jpenguin

Untitled

Jan 28th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. Index: src/lincity-ng/main.cpp
  2. ===================================================================
  3. --- src/lincity-ng/main.cpp (revision 1625)
  4. +++ src/lincity-ng/main.cpp (working copy)
  5. @@ -57,6 +57,10 @@
  6. tinygettext::DictionaryManager* dictionaryManager = 0;
  7. bool restart = false;
  8.  
  9. +#ifdef __APPLE__
  10. + extern char *getBundleSharePath(char *packageName);
  11. +#endif
  12. +
  13. void initPhysfs(const char* argv0)
  14. {
  15. if(!PHYSFS_init(argv0)) {
  16. @@ -145,30 +149,56 @@
  17. }
  18. }
  19.  
  20. -#if defined(APPDATADIR) || defined(ENABLE_BINRELOC)
  21. - std::string datadir;
  22. -#ifdef ENABLE_BINRELOC
  23. - BrInitError error;
  24. - if (br_init (&error) == 0 && error != BR_INIT_ERROR_DISABLED) {
  25. - printf ("Warning: BinReloc failed to initialize (error code %d)\n",
  26. - error);
  27. - printf ("Will fallback to hardcoded default path.\n");
  28. - }
  29. -
  30. - char* brdatadir = br_find_data_dir("/usr/local/share");
  31. - datadir = brdatadir;
  32. - datadir += "/" PACKAGE_NAME;
  33. - free(brdatadir);
  34. +#ifndef __APPLE__
  35. + #if defined(APPDATADIR) || defined(ENABLE_BINRELOC)
  36. + std::string datadir;
  37. + #ifdef ENABLE_BINRELOC
  38. + BrInitError error;
  39. + if (br_init (&error) == 0 && error != BR_INIT_ERROR_DISABLED) {
  40. + printf ("Warning: BinReloc failed to initialize (error code %d)\n",
  41. + error);
  42. + printf ("Will fallback to hardcoded default path.\n");
  43. + }
  44. +
  45. + char* brdatadir = br_find_data_dir("/usr/local/share");
  46. + datadir = brdatadir;
  47. + datadir += "/" PACKAGE_NAME;
  48. + free(brdatadir);
  49. + #else
  50. + datadir = APPDATADIR;
  51. + #endif
  52. +
  53. + if(!PHYSFS_addToSearchPath(datadir.c_str(), 1)) {
  54. + std::cout << "Couldn't add '" << datadir
  55. + << "' to physfs searchpath: " << PHYSFS_getLastError() << "\n";
  56. + }
  57. + #endif
  58. #else
  59. - datadir = APPDATADIR;
  60. + #if defined(APPDATADIR) || defined(ENABLE_BINRELOC) && __APPLE__
  61. + std::string datadir;
  62. + #ifdef ENABLE_BINRELOC
  63. + BrInitError error;
  64. + if (br_init (&error) == 0 && error != BR_INIT_ERROR_DISABLED) {
  65. + printf ("Warning: BinReloc failed to initialize (error code %d)\n",
  66. + error);
  67. + printf ("Will fallback to hardcoded default path.\n");
  68. + }
  69. +
  70. + char* brdatadir = br_find_data_dir("/usr/local/share");
  71. + datadir = brdatadir;
  72. + datadir += "/" PACKAGE_NAME;
  73. + free(brdatadir);
  74. + #else
  75. + datadir = APPDATADIR;
  76. + #endif
  77. + datadir = getBundleSharePath(PACKAGE_NAME);
  78. + if(!PHYSFS_addToSearchPath(datadir.c_str(), 1)) {
  79. + std::cout << "Couldn't add '" << datadir
  80. + << "' to physfs searchpath: " << PHYSFS_getLastError() << "\n";
  81. + }
  82. + #endif
  83. #endif
  84.  
  85. - if(!PHYSFS_addToSearchPath(datadir.c_str(), 1)) {
  86. - std::cout << "Couldn't add '" << datadir
  87. - << "' to physfs searchpath: " << PHYSFS_getLastError() << "\n";
  88. - }
  89. -#endif
  90. -
  91. // allow symbolic links
  92. PHYSFS_permitSymbolicLinks(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement