diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 7e72d450cf4..f5a0cc17ed0 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -271,6 +271,12 @@ AbstractFSNode *POSIXFilesystemNode::getParent() const { if (_path.size() == 3 && _path.hasSuffix(":/")) // This is a root directory of a drive return makeNode("/"); // return a virtual root for a list of drives +#elif defined(ANDROID_PLAIN_PORT) + Common::String pathCopy = _path; + pathCopy.trim(); + if (pathCopy.empty()) { + return makeNode("/"); // return a virtual root for a list of drives + } #endif const char *start = _path.c_str(); diff --git a/gui/browser.cpp b/gui/browser.cpp index 0b677ab152c..56689cab004 100644 --- a/gui/browser.cpp +++ b/gui/browser.cpp @@ -103,15 +103,23 @@ void BrowserDialog::open() { // Call super implementation Dialog::open(); - if (ConfMan.hasKey("browser_lastpath")) - _node = Common::FSNode(ConfMan.get("browser_lastpath")); #if defined(ANDROID_PLAIN_PORT) - else { // !ConfMan.hasKey("browser_lastpath")) - // Currently, the "default" path in Android port will present a list of shortcuts, (most of) which should be usable. - // The "/" will list these shortcuts (see POSIXFilesystemNode::getChildren()) - _node = Common::FSNode("/"); + // Currently, the "default" path in Android port will present a list of shortcuts, (most of) which should be usable. + // The "/" will list these shortcuts (see POSIXFilesystemNode::getChildren()) + Common::String blPath = "/"; + if (ConfMan.hasKey("browser_lastpath")) { + Common::String blPathCandidate = ConfMan.get("browser_lastpath"); + blPathCandidate.trim(); + if (!blPathCandidate.empty()) { + blPath = blPathCandidate; + } } -#endif // defined(ANDROID_PLAIN_PORT) + _node = Common::FSNode(blPath); +#else + if (ConfMan.hasKey("browser_lastpath") + _node = Common::FSNode(ConfMan.get("browser_lastpath")); +#endif + if (!_node.isDirectory()) _node = Common::FSNode("."); @@ -125,7 +133,23 @@ void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data switch (cmd) { //Search for typed-in directory case kPathEditedCmd: +#if defined(ANDROID_PLAIN_PORT) + { + // Currently, the "default" path in Android port will present a list of shortcuts, (most of) which should be usable. + // The "/" will list these shortcuts (see POSIXFilesystemNode::getChildren()) + // If the user enters an empty text or blank spaces for the path, then upon committing it as an edit, + // Android will show the list of shortcuts and default the path text field to "/". + // The code is placed in brackets for edtPath var to have proper local scope in this particular switch case. + Common::String edtPath = Common::convertFromU32String(_currentPath->getEditString()); + edtPath.trim(); + if (edtPath.empty()) { + edtPath = "/"; + } + _node = Common::FSNode(edtPath); + } +#else _node = Common::FSNode(Common::convertFromU32String(_currentPath->getEditString())); +#endif updateListing(); break; //Search by text input