mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2025-02-16 23:54:42 +02: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:
parent
7fb67ba1cc
commit
28a041ea80
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "FastDelegate.h"
|
#include "FastDelegate.h"
|
||||||
#include "filelister.h"
|
#include "filelister.h"
|
||||||
|
#include "gmenu2x.h"
|
||||||
|
|
||||||
using namespace fastdelegate;
|
using namespace fastdelegate;
|
||||||
|
|
||||||
@ -40,8 +41,8 @@ bool BrowseDialog::exec()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
string path = fl->getPath();
|
string path = fl->getPath();
|
||||||
if (path.empty() || !fileExists(path) || path.compare(0, 5, "/card") != 0)
|
if (path.empty() || !fileExists(path) || path.compare(0, 5, CARD_ROOT) != 0)
|
||||||
setPath("/card");
|
setPath(CARD_ROOT);
|
||||||
|
|
||||||
fl->browse();
|
fl->browse();
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ void BrowseDialog::directoryUp()
|
|||||||
if (p == path.size() - 1)
|
if (p == path.size() - 1)
|
||||||
p = path.rfind("/", p - 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;
|
close = true;
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "filedialog.h"
|
#include "filedialog.h"
|
||||||
|
#include "gmenu2x.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ FileDialog::FileDialog(GMenu2X *gmenu2x, const string &text,
|
|||||||
const string &filter, const string &file, const string &title) :
|
const string &filter, const string &file, const string &title) :
|
||||||
BrowseDialog(gmenu2x, title, text)
|
BrowseDialog(gmenu2x, title, text)
|
||||||
{
|
{
|
||||||
string path = "/card";
|
string path(CARD_ROOT);
|
||||||
if (!file.empty()) {
|
if (!file.empty()) {
|
||||||
string::size_type pos = file.rfind("/");
|
string::size_type pos = file.rfind("/");
|
||||||
if (pos != string::npos)
|
if (pos != string::npos)
|
||||||
|
@ -76,6 +76,8 @@
|
|||||||
//#include <pnd_discovery.h>
|
//#include <pnd_discovery.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char *CARD_ROOT = "/card";
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fastdelegate;
|
using namespace fastdelegate;
|
||||||
|
|
||||||
@ -420,7 +422,7 @@ void GMenu2X::initMenu() {
|
|||||||
menu->loadIcons();
|
menu->loadIcons();
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
//menu->addLink( "/card", "sample.pxml", "applications" );
|
//menu->addLink( CARD_ROOT, "sample.pxml", "applications" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::about() {
|
void GMenu2X::about() {
|
||||||
@ -1025,7 +1027,7 @@ void GMenu2X::options() {
|
|||||||
int curGlobalVolume = confInt["globalVolume"];
|
int curGlobalVolume = confInt["globalVolume"];
|
||||||
//G
|
//G
|
||||||
int prevbacklight = confInt["backlight"];
|
int prevbacklight = confInt["backlight"];
|
||||||
bool showRootFolder = fileExists("/card");
|
bool showRootFolder = fileExists(CARD_ROOT);
|
||||||
|
|
||||||
FileLister fl_tr("translations");
|
FileLister fl_tr("translations");
|
||||||
fl_tr.browse();
|
fl_tr.browse();
|
||||||
@ -1055,10 +1057,10 @@ void GMenu2X::options() {
|
|||||||
if (curGlobalVolume!=confInt["globalVolume"]) setVolume(confInt["globalVolume"]);
|
if (curGlobalVolume!=confInt["globalVolume"]) setVolume(confInt["globalVolume"]);
|
||||||
if (lang == "English") lang = "";
|
if (lang == "English") lang = "";
|
||||||
if (lang != tr.lang()) tr.setLang(lang);
|
if (lang != tr.lang()) tr.setLang(lang);
|
||||||
if (fileExists("/card") && !showRootFolder)
|
if (fileExists(CARD_ROOT) && !showRootFolder)
|
||||||
unlink("/card");
|
unlink(CARD_ROOT);
|
||||||
else if (!fileExists("/card") && showRootFolder)
|
else if (!fileExists(CARD_ROOT) && showRootFolder)
|
||||||
symlink("/","/card");
|
symlink("/", CARD_ROOT);
|
||||||
writeConfig();
|
writeConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1603,7 +1605,7 @@ void GMenu2X::scanner() {
|
|||||||
lineY += 26;
|
lineY += 26;
|
||||||
|
|
||||||
vector<string> files;
|
vector<string> files;
|
||||||
scanPath("/card",&files);
|
scanPath(CARD_ROOT, &files);
|
||||||
|
|
||||||
//Onyl gph firmware has nand
|
//Onyl gph firmware has nand
|
||||||
/* if (fwType=="gph" && !f200) {
|
/* if (fwType=="gph" && !f200) {
|
||||||
@ -1890,7 +1892,7 @@ string GMenu2X::getDiskFree() {
|
|||||||
string df = "";
|
string df = "";
|
||||||
struct statvfs b;
|
struct statvfs b;
|
||||||
|
|
||||||
int ret = statvfs("/card", &b);
|
int ret = statvfs(CARD_ROOT, &b);
|
||||||
if (ret==0) {
|
if (ret==0) {
|
||||||
// Make sure that the multiplication happens in 64 bits.
|
// Make sure that the multiplication happens in 64 bits.
|
||||||
unsigned long long free =
|
unsigned long long free =
|
||||||
|
@ -45,6 +45,8 @@ const int BATTERY_READS = 10;
|
|||||||
|
|
||||||
const int LOOP_DELAY=30000;
|
const int LOOP_DELAY=30000;
|
||||||
|
|
||||||
|
extern const char *CARD_ROOT;
|
||||||
|
|
||||||
extern void jz_cpuspeed(unsigned clockspeed);
|
extern void jz_cpuspeed(unsigned clockspeed);
|
||||||
|
|
||||||
enum color {
|
enum color {
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "linkapp.h"
|
#include "linkapp.h"
|
||||||
#include "selector.h"
|
#include "selector.h"
|
||||||
#include "filelister.h"
|
#include "filelister.h"
|
||||||
|
#include "gmenu2x.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ int Selector::exec(int startSelection) {
|
|||||||
if ( gmenu2x->input[ACTION_X] ) {
|
if ( gmenu2x->input[ACTION_X] ) {
|
||||||
if (link->getSelectorBrowser()) {
|
if (link->getSelectorBrowser()) {
|
||||||
string::size_type p = dir.rfind("/", dir.size()-2);
|
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;
|
close = true;
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user