BADA: Hardcoded file system paths now defined as macros

This commit is contained in:
Chris Warren-Smith 2011-08-16 19:39:15 +10:00
parent 028a67012d
commit 7836a0ff20

View file

@ -25,6 +25,17 @@
#define BUFFER_SIZE 1024 #define BUFFER_SIZE 1024
// internal BADA paths
#define PATH_ROOT "/"
#define PATH_HOME "/Home"
#define PATH_HOME_SHARE "/Home/Share"
#define PATH_HOME_SHARE2 "/Home/Share2"
#define PATH_HOME_X "/Home/"
#define PATH_HOME_EXT "/HomeExt"
#define PATH_MEDIA "/Media"
#define PATH_CARD "/Storagecard"
#define PATH_CARD_MEDIA "/Storagecard/Media"
// //
// BadaFileStream // BadaFileStream
// //
@ -211,7 +222,7 @@ BadaFileStream *BadaFileStream::makeFromPath(const String &path, bool writeMode)
String filePath = path; String filePath = path;
if (writeMode && (path[0] != '.' && path[0] != '/')) { if (writeMode && (path[0] != '.' && path[0] != '/')) {
filePath.Insert("/Home/", 0); filePath.Insert(PATH_HOME_X, 0);
} }
AppLog("Open file %S", filePath.GetPointer()); AppLog("Open file %S", filePath.GetPointer());
@ -267,11 +278,11 @@ void BadaFilesystemNode::init(const Common::String &nodePath) {
_displayName = Common::lastPathComponent(_path, '/'); _displayName = Common::lastPathComponent(_path, '/');
StringUtil::Utf8ToString(_path.c_str(), _unicodePath); StringUtil::Utf8ToString(_path.c_str(), _unicodePath);
_isVirtualDir = (_path == "/" || _isVirtualDir = (_path == PATH_ROOT ||
_path == "/Home" || _path == PATH_HOME ||
_path == "/Home/Share" || _path == PATH_HOME_SHARE ||
_path == "/Home/Share2" || _path == PATH_HOME_SHARE2 ||
_path == "/Storagecard"); _path == PATH_CARD);
_isValid = _isVirtualDir || !IsFailed(File::GetAttributes(_unicodePath, _attr)); _isValid = _isVirtualDir || !IsFailed(File::GetAttributes(_unicodePath, _attr));
} }
@ -289,10 +300,10 @@ bool BadaFilesystemNode::isDirectory() const {
bool BadaFilesystemNode::isWritable() const { bool BadaFilesystemNode::isWritable() const {
bool result = (_isValid && !_isVirtualDir && !_attr.IsDirectory() && !_attr.IsReadOnly()); bool result = (_isValid && !_isVirtualDir && !_attr.IsDirectory() && !_attr.IsReadOnly());
if (_path == "/Home" || if (_path == PATH_HOME ||
_path == "/HomeExt" || _path == PATH_HOME_EXT ||
_path == "/Home/Share" || _path == PATH_HOME_SHARE ||
_path == "/Home/Share2") { _path == PATH_HOME_SHARE2) {
result = true; result = true;
} }
return result; return result;
@ -312,19 +323,19 @@ bool BadaFilesystemNode::getChildren(AbstractFSList &myList,
if (_isVirtualDir && mode != Common::FSNode::kListFilesOnly) { if (_isVirtualDir && mode != Common::FSNode::kListFilesOnly) {
// present well known BADA file system areas // present well known BADA file system areas
if (_path == "/") { if (_path == PATH_ROOT) {
myList.push_back(new BadaFilesystemNode("/Home")); myList.push_back(new BadaFilesystemNode(PATH_HOME));
myList.push_back(new BadaFilesystemNode("/HomeExt")); myList.push_back(new BadaFilesystemNode(PATH_HOME_EXT));
myList.push_back(new BadaFilesystemNode("/Media")); myList.push_back(new BadaFilesystemNode(PATH_MEDIA));
myList.push_back(new BadaFilesystemNode("/Storagecard")); myList.push_back(new BadaFilesystemNode(PATH_CARD));
result = true; // no more entries result = true; // no more entries
} else if (_path == "/Storagecard") { } else if (_path == PATH_CARD) {
myList.push_back(new BadaFilesystemNode("/Storagecard/Media")); myList.push_back(new BadaFilesystemNode(PATH_CARD_MEDIA));
result = true; // no more entries result = true; // no more entries
} else if (_path == "/Home") { } else if (_path == PATH_HOME) {
// ensure share path is always included // ensure share path is always included
myList.push_back(new BadaFilesystemNode("/Home/Share")); myList.push_back(new BadaFilesystemNode(PATH_HOME_SHARE));
myList.push_back(new BadaFilesystemNode("/Home/Share2")); myList.push_back(new BadaFilesystemNode(PATH_HOME_SHARE2));
} }
} }
@ -384,7 +395,7 @@ bool BadaFilesystemNode::getChildren(AbstractFSList &myList,
AbstractFSNode *BadaFilesystemNode::getParent() const { AbstractFSNode *BadaFilesystemNode::getParent() const {
logEntered(); logEntered();
if (_path == "/") { if (_path == PATH_ROOT) {
return 0; // The filesystem root has no parent return 0; // The filesystem root has no parent
} }