From 6381674f571c5c5169b14b6c2f63262808cf613e Mon Sep 17 00:00:00 2001 From: bartbes Date: Wed, 1 Sep 2010 17:37:27 +0200 Subject: [PATCH] Fixed segfault when CARD_ROOT didn't exist & added _CARD_ROOT compile-time define to set CARD_ROOT Note that you shouldn't set CARD_ROOT (or _CARD_ROOT) to /, because that might mess things up. --- src/gmenu2x.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 508c162..a7c4bd5 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -77,7 +77,11 @@ //#include #endif +#ifdef _CARD_ROOT +const char *CARD_ROOT = _CARD_ROOT; +#else const char *CARD_ROOT = "/card/"; //Note: Add a trailing /! +#endif const int CARD_ROOT_LEN = 5; using namespace std; @@ -1064,11 +1068,11 @@ void GMenu2X::options() { if (curGlobalVolume!=confInt["globalVolume"]) setVolume(confInt["globalVolume"]); if (lang == "English") lang = ""; if (lang != tr.lang()) tr.setLang(lang); - /*if (fileExists(CARD_ROOT) && !showRootFolder) + if (fileExists(CARD_ROOT) && !showRootFolder) unlink(CARD_ROOT); else if (!fileExists(CARD_ROOT) && showRootFolder) - symlink("/", CARD_ROOT);*/ - //WARNING: Disabled because these functions get dangerous when run with / as CARD_ROOT + symlink("/", CARD_ROOT); + //WARNING: the above might be dangerous with CARD_ROOT set to / writeConfig(); } }