CLOUD: Make "/create" work

One can now create directories through browser.
This commit is contained in:
Alexander Tkachev 2016-07-06 18:03:56 +06:00
parent 48e3fff6bc
commit ab4361a76b
7 changed files with 119 additions and 2 deletions

View file

@ -44,6 +44,7 @@ LocalWebserver::LocalWebserver(): _set(nullptr), _serverSocket(nullptr), _timerS
_stopOnIdle(false), _clients(0), _idlingFrames(0) {
addPathHandler("/", _indexPageHandler.getHandler());
addPathHandler("/files", _filesPageHandler.getHandler());
addPathHandler("/create", _filesPageHandler.getHandler()); //"Create directory" feature
_defaultHandler = _resourceHandler.getHandler();
}
@ -271,4 +272,32 @@ const char *LocalWebserver::determineMimeType(Common::String &filename) {
return "application/octet-stream";
}
namespace {
int hexDigit(char c) {
if ('0' <= c && c <= '9') return c - '0';
if ('A' <= c && c <= 'F') return c - 'A' + 10;
if ('a' <= c && c <= 'f') return c - 'a' + 10;
return -1;
}
}
Common::String LocalWebserver::urlDecode(Common::String value) {
Common::String result = "";
uint32 size = value.size();
for (uint32 i = 0; i < size; ++i) {
if (value[i] == '%' && i+2 < size) {
int d1 = hexDigit(value[i+1]);
int d2 = hexDigit(value[i+2]);
if (0 <= d1 && d1 < 16 && 0 <= d2 && d2 < 16) {
result += (char)(d1 * 16 + d2);
i = i + 2;
continue;
}
}
result += value[i];
}
return result;
}
} // End of namespace Networking