aboutsummaryrefslogtreecommitdiff
path: root/backends/networking/sdl_net/handlers/filespagehandler.cpp
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-06 18:33:34 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit8a9d126152f3e0ed1e91daa15dd90f0c18060492 (patch)
treed9f96a1f15e041ea493a7077ba1ab4ccc52a7da4 /backends/networking/sdl_net/handlers/filespagehandler.cpp
parentab4361a76b40b56348ec46311121a0552f0c9d6b (diff)
downloadscummvm-rg350-8a9d126152f3e0ed1e91daa15dd90f0c18060492.tar.gz
scummvm-rg350-8a9d126152f3e0ed1e91daa15dd90f0c18060492.tar.bz2
scummvm-rg350-8a9d126152f3e0ed1e91daa15dd90f0c18060492.zip
CLOUD: Move "/create" to separate Handler
It does redirect to "/files" on success, so user doesn't even see the strange "/create" URL at all. This commit is for keeping these handlers small, not making one (FilesPageHandler in this case) do everything.
Diffstat (limited to 'backends/networking/sdl_net/handlers/filespagehandler.cpp')
-rw-r--r--backends/networking/sdl_net/handlers/filespagehandler.cpp71
1 files changed, 0 insertions, 71 deletions
diff --git a/backends/networking/sdl_net/handlers/filespagehandler.cpp b/backends/networking/sdl_net/handlers/filespagehandler.cpp
index 327071fc11..2ecb448c3c 100644
--- a/backends/networking/sdl_net/handlers/filespagehandler.cpp
+++ b/backends/networking/sdl_net/handlers/filespagehandler.cpp
@@ -22,7 +22,6 @@
#include "backends/networking/sdl_net/handlers/filespagehandler.h"
#include "backends/networking/sdl_net/localwebserver.h"
-#include "backends/fs/fs-factory.h"
#include "common/file.h"
#include "common/translation.h"
@@ -36,11 +35,6 @@ FilesPageHandler::FilesPageHandler() {}
FilesPageHandler::~FilesPageHandler() {}
void FilesPageHandler::handle(Client &client) {
- if (client.path() == "/files") handleFiles(client);
- else handleCreateDirectory(client);
-}
-
-void FilesPageHandler::handleFiles(Client &client) {
Common::String response = "<html><head><title>ScummVM</title></head><body><table>{content}</table></body></html>"; //TODO: add controls
Common::String itemTemplate = "<tr><td><a href=\"{link}\">{name}</a></td><td>{size}</td></tr>\n"; //TODO: load this template too?
@@ -77,27 +71,6 @@ void FilesPageHandler::handleFiles(Client &client) {
LocalWebserver::setClientGetHandler(client, response);
}
-void FilesPageHandler::handleCreateDirectory(Client &client) {
- Common::String path = client.queryParameter("path");
- Common::String name = client.queryParameter("directory_name");
- Common::String errorMessage = "";
-
- // show an error message if failed to create directory
- if (!createDirectory(path, name, errorMessage)) {
- handleErrorMessage(
- client,
- Common::String::format(
- "%s<br/><a href=\"files?path=/\">%s</a>",
- errorMessage.c_str(),
- _("Back to the files manager")
- )
- );
- return;
- }
-
- handleFiles(client);
-}
-
void FilesPageHandler::handleErrorMessage(Client &client, Common::String message) {
Common::String response = "<html><head><title>ScummVM</title></head><body>{message}</body></html>";
@@ -109,50 +82,6 @@ void FilesPageHandler::handleErrorMessage(Client &client, Common::String message
LocalWebserver::setClientGetHandler(client, response);
}
-bool FilesPageHandler::createDirectory(Common::String path, Common::String name, Common::String &errorMessage) {
- // check that <path> is not an absolute root
- if (path == "" || path == "/") {
- errorMessage = _("Can't create directory here!");
- return false;
- }
-
- // transform virtual path to actual file system one
- Common::String prefixToRemove = "", prefixToAdd = "";
- if (!transformPath(path, prefixToRemove, prefixToAdd) || path.empty()) {
- errorMessage = _("Invalid path!");
- return false;
- }
-
- // check that <path> exists and is directory
- AbstractFSNode *node = g_system->getFilesystemFactory()->makeFileNodePath(path);
- if (!node->exists()) {
- errorMessage = _("Parent directory doesn't exists!");
- return false;
- }
- if (!node->isDirectory()) {
- errorMessage = _("Can't create a directory within a file!");
- return false;
- }
-
- // check that <directory_name> doesn't exist or is directory
- if (path.lastChar() != '/' && path.lastChar() != '\\') path += '/';
- node = g_system->getFilesystemFactory()->makeFileNodePath(path + name);
- if (node->exists()) {
- if (!node->isDirectory()) {
- errorMessage = _("There is a file with that name in the parent directory!");
- return false;
- } else return true;
- }
-
- // create the <directory_name> in <path>
- if (!node->create(true)) {
- errorMessage = _("Failed to create the directory!");
- return false;
- }
-
- return true;
-}
-
bool FilesPageHandler::listDirectory(Common::String path, Common::String &content, const Common::String &itemTemplate) {
if (path == "" || path == "/") {
addItem(content, itemTemplate, true, "/root/", _("File system root"));