ANDROID: More safeguards against empty path in browser
This commit is contained in:
parent
064684fd16
commit
3ee5a99619
2 changed files with 37 additions and 7 deletions
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue