Commit b38b8b9c authored by Max Kellermann's avatar Max Kellermann

db/upnp: simplify Namei()

parent 54348561
...@@ -481,16 +481,18 @@ UpnpDatabase::Namei(ContentDirectoryService &server, ...@@ -481,16 +481,18 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
std::string objid(rootid); std::string objid(rootid);
// Walk the path elements, read each directory and try to find the next one // Walk the path elements, read each directory and try to find the next one
for (auto i = vpath.begin(), end = vpath.end(), last = std::prev(end); for (auto i = vpath.begin(), last = std::prev(vpath.end());; ++i) {
i != end; ++i) {
UPnPDirContent dirbuf; UPnPDirContent dirbuf;
if (!server.readDir(handle, objid.c_str(), dirbuf, error)) if (!server.readDir(handle, objid.c_str(), dirbuf, error))
return false; return false;
// Look for the name in the sub-container list // Look for the name in the sub-container list
UPnPDirObject *child = dirbuf.FindObject(i->c_str()); UPnPDirObject *child = dirbuf.FindObject(i->c_str());
if (child == nullptr) if (child == nullptr) {
break; error.Format(db_domain, DB_NOT_FOUND,
"No such object");
return false;
}
switch (child->type) { switch (child->type) {
case UPnPDirObject::Type::UNKNOWN: case UPnPDirObject::Type::UNKNOWN:
...@@ -520,9 +522,6 @@ UpnpDatabase::Namei(ContentDirectoryService &server, ...@@ -520,9 +522,6 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
} }
} }
} }
error.Format(db_domain, DB_NOT_FOUND, "No such object");
return false;
} }
// vpath is a parsed and writeable version of selection.uri. There is // vpath is a parsed and writeable version of selection.uri. There is
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment