Date:2012-06-24 23:19:45 (11 years 9 months ago)
Author:Paul Cercueil
Commit:1241523105c31488741086f0532e7da83e2050ad
Message:Removed variable/function to get the directory of the executable.

The application shouldn't care from which directory it is being
executed.
Files: src/gmenu2x.cpp (3 diffs)
src/gmenu2x.h (2 diffs)
src/linkapp.cpp (1 diff)

Change Details

src/gmenu2x.cpp
255255    bottomBarIconY = resY-18;
256256    bottomBarTextY = resY-10;
257257
258    path = "";
259    getExePath();
260
261258#ifdef UNLOCK_VT
262259    unlockVT();
263260#endif
...... 
839836        if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex()))
840837            writeConfig();
841838
842        //string command = cmdclean(fd.path()+"/"+fd.file) + "; sync & cd "+cmdclean(getExePath())+"; exec ./gmenu2x";
843839        string command = cmdclean(fd.getPath()+"/"+fd.getFile());
844840        chdir(fd.getPath().c_str());
845841        quit();
...... 
14831479#endif
14841480}
14851481
1486const string &GMenu2X::getExePath() {
1487    if (path.empty()) {
1488        char buf[255];
1489        memset(buf, 0, 255);
1490        int l = readlink("/proc/self/exe", buf, 255);
1491
1492        path = buf;
1493        path = path.substr(0,l);
1494        l = path.rfind("/");
1495        path = path.substr(0,l+1);
1496    }
1497    return path;
1498}
1499
15001482string GMenu2X::getDiskFree(const char *path) {
15011483    stringstream ss;
15021484    string df = "";
src/gmenu2x.h
6565class GMenu2X {
6666private:
6767    Touchscreen ts;
68    std::string path; //!< Contains the working directory of GMenu2X
6968
7069    /*!
7170    Retrieves the free disk space on the sd
...... 
134133    uint resX, resY, halfX, halfY;
135134    uint bottomBarIconY, bottomBarTextY, linkColumns, linkRows;
136135
137    /*!
138    Retrieves the parent directory of GMenu2X.
139    This functions is used to initialize the "path" variable.
140    @see path
141    @return String containing the parent directory
142    */
143    const std::string &getExePath();
144
145136    InputManager input;
146137
147138    //Configuration hashes
src/linkapp.cpp
464464        //try relaunching gmenu2x
465465        gmenu2x->main();
466466    }
467
468    chdir(gmenu2x->getExePath().c_str());
469467}
470468
471469const string &LinkApp::getExec() {

Archive Download the corresponding diff file



interactive