1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 18:05:26 +03:00

Add constant for SD card root.

In the future, this should be part of a device abstraction, but having a single constant is an improvement over having duplicated string literals.
This commit is contained in:
Maarten ter Huurne 2010-07-04 03:19:52 +02:00
parent 7fb67ba1cc
commit 28a041ea80
5 changed files with 20 additions and 13 deletions

View File

@ -4,6 +4,7 @@
#include "FastDelegate.h"
#include "filelister.h"
#include "gmenu2x.h"
using namespace fastdelegate;
@ -40,8 +41,8 @@ bool BrowseDialog::exec()
return false;
string path = fl->getPath();
if (path.empty() || !fileExists(path) || path.compare(0, 5, "/card") != 0)
setPath("/card");
if (path.empty() || !fileExists(path) || path.compare(0, 5, CARD_ROOT) != 0)
setPath(CARD_ROOT);
fl->browse();
@ -161,7 +162,7 @@ void BrowseDialog::directoryUp()
if (p == path.size() - 1)
p = path.rfind("/", p - 1);
if (p == string::npos || p < 4 || path.compare(0, 5, "/card") != 0) {
if (p == string::npos || p < 4 || path.compare(0, 5, CARD_ROOT) != 0) {
close = true;
result = false;
} else {

View File

@ -19,6 +19,7 @@
***************************************************************************/
#include "filedialog.h"
#include "gmenu2x.h"
using namespace std;
@ -26,7 +27,7 @@ FileDialog::FileDialog(GMenu2X *gmenu2x, const string &text,
const string &filter, const string &file, const string &title) :
BrowseDialog(gmenu2x, title, text)
{
string path = "/card";
string path(CARD_ROOT);
if (!file.empty()) {
string::size_type pos = file.rfind("/");
if (pos != string::npos)

View File

@ -76,6 +76,8 @@
//#include <pnd_discovery.h>
#endif
const char *CARD_ROOT = "/card";
using namespace std;
using namespace fastdelegate;
@ -420,7 +422,7 @@ void GMenu2X::initMenu() {
menu->loadIcons();
//DEBUG
//menu->addLink( "/card", "sample.pxml", "applications" );
//menu->addLink( CARD_ROOT, "sample.pxml", "applications" );
}
void GMenu2X::about() {
@ -1025,7 +1027,7 @@ void GMenu2X::options() {
int curGlobalVolume = confInt["globalVolume"];
//G
int prevbacklight = confInt["backlight"];
bool showRootFolder = fileExists("/card");
bool showRootFolder = fileExists(CARD_ROOT);
FileLister fl_tr("translations");
fl_tr.browse();
@ -1055,10 +1057,10 @@ void GMenu2X::options() {
if (curGlobalVolume!=confInt["globalVolume"]) setVolume(confInt["globalVolume"]);
if (lang == "English") lang = "";
if (lang != tr.lang()) tr.setLang(lang);
if (fileExists("/card") && !showRootFolder)
unlink("/card");
else if (!fileExists("/card") && showRootFolder)
symlink("/","/card");
if (fileExists(CARD_ROOT) && !showRootFolder)
unlink(CARD_ROOT);
else if (!fileExists(CARD_ROOT) && showRootFolder)
symlink("/", CARD_ROOT);
writeConfig();
}
}
@ -1603,7 +1605,7 @@ void GMenu2X::scanner() {
lineY += 26;
vector<string> files;
scanPath("/card",&files);
scanPath(CARD_ROOT, &files);
//Onyl gph firmware has nand
/* if (fwType=="gph" && !f200) {
@ -1890,7 +1892,7 @@ string GMenu2X::getDiskFree() {
string df = "";
struct statvfs b;
int ret = statvfs("/card", &b);
int ret = statvfs(CARD_ROOT, &b);
if (ret==0) {
// Make sure that the multiplication happens in 64 bits.
unsigned long long free =

View File

@ -45,6 +45,8 @@ const int BATTERY_READS = 10;
const int LOOP_DELAY=30000;
extern const char *CARD_ROOT;
extern void jz_cpuspeed(unsigned clockspeed);
enum color {

View File

@ -31,6 +31,7 @@
#include "linkapp.h"
#include "selector.h"
#include "filelister.h"
#include "gmenu2x.h"
using namespace std;
@ -151,7 +152,7 @@ int Selector::exec(int startSelection) {
if ( gmenu2x->input[ACTION_X] ) {
if (link->getSelectorBrowser()) {
string::size_type p = dir.rfind("/", dir.size()-2);
if (p==string::npos || dir.compare(0, 5, "/card") != 0 || p<4) {
if (p==string::npos || dir.compare(0, 5, CARD_ROOT) != 0 || p<4) {
close = true;
result = false;
} else {