1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-27 10:36:27 +02:00

Added a static function GMenu2X::getHome() that returns GMenu2X's user-specific directory (usually ~/.gmenu2x).

This commit is contained in:
Ayla 2011-03-29 12:15:16 +02:00
parent 758b7b183c
commit 8693dff072
2 changed files with 24 additions and 0 deletions

View File

@ -87,6 +87,7 @@ const char *CARD_ROOT = "/card/"; //Note: Add a trailing /!
const int CARD_ROOT_LEN = 5;
static GMenu2X *app;
static string gmenu2x_home;
using namespace std;
using namespace fastdelegate;
@ -121,6 +122,11 @@ static void quit_all(int err) {
exit(err);
}
const string GMenu2X::getHome(void)
{
return gmenu2x_home;
}
int main(int /*argc*/, char * /*argv*/[]) {
INFO("----\nGMenu2X starting: If you read this message in the logs, check http://gmenu2x.sourceforge.net/page/Troubleshooting for a solution\n----\n");
@ -128,6 +134,20 @@ int main(int /*argc*/, char * /*argv*/[]) {
signal(SIGSEGV,&quit_all);
signal(SIGTERM,&quit_all);
char *home = getenv("HOME");
if (home == NULL) {
ERROR("Unable to find gmenu2x home directory. The $HOME variable is not defined.\n");
return 1;
}
gmenu2x_home = (string)home + (string)"/.gmenu2x";
if (!fileExists(gmenu2x_home) && mkdir(gmenu2x_home.c_str(), 0770) < 0) {
ERROR("Unable to create gmenu2x home directory.\n");
return 1;
}
DEBUG("Home path: %s.\n", gmenu2x_home.c_str());
app = new GMenu2X();
DEBUG("Starting main()\n");
app->main();

View File

@ -155,6 +155,10 @@ public:
~GMenu2X();
void quit();
/* Returns the home directory of gmenu2x, usually
* ~/.gmenu2x */
static const string getHome(void);
/*
* Variables needed for elements disposition
*/