aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-17 13:05:45 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commita56c7a3bd608d310cf0a3c3b534a20e826ecf8f0 (patch)
treebdc980dab56115c9fd4e5162bea751876db02896 /backends
parentc2c2ba908ff916e0ba680596bb1b565069255a67 (diff)
downloadscummvm-rg350-a56c7a3bd608d310cf0a3c3b534a20e826ecf8f0.tar.gz
scummvm-rg350-a56c7a3bd608d310cf0a3c3b534a20e826ecf8f0.tar.bz2
scummvm-rg350-a56c7a3bd608d310cf0a3c3b534a20e826ecf8f0.zip
CLOUD: Update IndexPageHandler to search wwwroot.zip
Now it also searches for that in themepath, not with SearchMan only.
Diffstat (limited to 'backends')
-rw-r--r--backends/networking/sdl_net/indexpagehandler.cpp55
-rw-r--r--backends/networking/sdl_net/indexpagehandler.h1
2 files changed, 33 insertions, 23 deletions
diff --git a/backends/networking/sdl_net/indexpagehandler.cpp b/backends/networking/sdl_net/indexpagehandler.cpp
index 37fcac6419..a1a426d048 100644
--- a/backends/networking/sdl_net/indexpagehandler.cpp
+++ b/backends/networking/sdl_net/indexpagehandler.cpp
@@ -23,6 +23,7 @@
#include "backends/networking/sdl_net/indexpagehandler.h"
#include "backends/networking/sdl_net/localwebserver.h"
#include "common/archive.h"
+#include "common/config-manager.h"
#include "common/file.h"
#include "common/translation.h"
#include "common/unzip.h"
@@ -101,44 +102,52 @@ void IndexPageHandler::replace(Common::String &source, const Common::String &wha
}
}
-Common::ArchiveMemberList IndexPageHandler::listArchive() {
- Common::ArchiveMemberList resultList;
+Common::Archive *IndexPageHandler::getZipArchive() {
+ // first search in themepath
+ if (ConfMan.hasKey("themepath")) {
+ const Common::FSNode &node = Common::FSNode(ConfMan.get("themepath"));
+ if (!node.exists() || !node.isReadable() || !node.isDirectory())
+ return false;
+
+ Common::FSNode fileNode = node.getChild(ARCHIVE_NAME);
+ if (fileNode.exists() && fileNode.isReadable() && !fileNode.isDirectory()) {
+ Common::SeekableReadStream *const stream = fileNode.createReadStream();
+ Common::Archive *zipArchive = Common::makeZipArchive(stream);
+ if (zipArchive) return zipArchive;
+ }
+ }
- // Find "wwwroot.zip" with SearchMan and call its listMembers()
+ // then use SearchMan to find it
Common::ArchiveMemberList fileList;
SearchMan.listMatchingMembers(fileList, ARCHIVE_NAME);
for (Common::ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) {
Common::ArchiveMember const &m = **it;
Common::SeekableReadStream *const stream = m.createReadStream();
Common::Archive *zipArchive = Common::makeZipArchive(stream);
- if (zipArchive) {
- zipArchive->listMembers(resultList);
- delete zipArchive;
- break;
- }
+ if (zipArchive) return zipArchive;
}
+ return nullptr;
+}
+
+Common::ArchiveMemberList IndexPageHandler::listArchive() {
+ Common::ArchiveMemberList resultList;
+ Common::Archive *zipArchive = getZipArchive();
+ if (zipArchive) {
+ zipArchive->listMembers(resultList);
+ delete zipArchive;
+ }
return resultList;
}
Common::SeekableReadStream *const IndexPageHandler::getArchiveFile(Common::String name) {
Common::SeekableReadStream *result = nullptr;
-
- // Find "wwwroot.zip" with SearchMan and call its getMember(name)
- Common::ArchiveMemberList fileList;
- SearchMan.listMatchingMembers(fileList, ARCHIVE_NAME);
- for (Common::ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) {
- Common::ArchiveMember const &m = **it;
- Common::SeekableReadStream *const stream = m.createReadStream();
- Common::Archive *zipArchive = Common::makeZipArchive(stream);
- if (zipArchive) {
- const Common::ArchiveMemberPtr ptr = zipArchive->getMember(name);
- result = ptr->createReadStream();
- delete zipArchive;
- break;
- }
+ Common::Archive *zipArchive = getZipArchive();
+ if (zipArchive) {
+ const Common::ArchiveMemberPtr ptr = zipArchive->getMember(name);
+ result = ptr->createReadStream();
+ delete zipArchive;
}
-
return result;
}
diff --git a/backends/networking/sdl_net/indexpagehandler.h b/backends/networking/sdl_net/indexpagehandler.h
index 143c300336..df509a42b5 100644
--- a/backends/networking/sdl_net/indexpagehandler.h
+++ b/backends/networking/sdl_net/indexpagehandler.h
@@ -37,6 +37,7 @@ class IndexPageHandler: public GUI::CommandSender {
void handleResource(Client &client);
void replace(Common::String &source, const Common::String &what, const Common::String &with);
+ Common::Archive *getZipArchive();
Common::ArchiveMemberList listArchive();
Common::SeekableReadStream *const getArchiveFile(Common::String name);
Common::String readEverythingFromStream(Common::SeekableReadStream *const stream);