mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 20:06:49 +01:00
Use HashMap in BrowsableFolderServeWebPage, as the bug that was preventing this was already fixed quite a while ago.
This commit is contained in:
parent
61cecf068a
commit
602d8a6836
@ -51,21 +51,19 @@ void BrowsableFolderServeWebPage::set_should_render_menu(const bool &val) {
|
|||||||
void BrowsableFolderServeWebPage::_handle_request(Ref<WebServerRequest> request) {
|
void BrowsableFolderServeWebPage::_handle_request(Ref<WebServerRequest> request) {
|
||||||
String file_name = request->get_path(true, false);
|
String file_name = request->get_path(true, false);
|
||||||
|
|
||||||
for (int i = 0; i < _folder_indexes.size(); ++i) {
|
String *data = _folder_indexes.getptr(file_name);
|
||||||
const BFSNEntry &e = _folder_indexes[i];
|
|
||||||
|
if (!data) {
|
||||||
|
request->send_error(HTTPServerEnums::HTTP_STATUS_CODE_404_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.uri == file_name) {
|
|
||||||
if (_should_render_menu) {
|
if (_should_render_menu) {
|
||||||
render_menu(request);
|
render_menu(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
request->body += e.data;
|
request->body += *data;
|
||||||
request->compile_and_send_body();
|
request->compile_and_send_body();
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
request->send_error(HTTPServerEnums::HTTP_STATUS_CODE_404_NOT_FOUND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowsableFolderServeWebPage::_render_index(Ref<WebServerRequest> request) {
|
void BrowsableFolderServeWebPage::_render_index(Ref<WebServerRequest> request) {
|
||||||
@ -106,7 +104,7 @@ void BrowsableFolderServeWebPage::evaluate_dir(const String &path, const bool to
|
|||||||
|
|
||||||
String file = dir->get_next();
|
String file = dir->get_next();
|
||||||
|
|
||||||
while (file != "") {
|
while (!file.empty()) {
|
||||||
String np = path.append_path(file);
|
String np = path.append_path(file);
|
||||||
String nnp = np.substr(serve_folder.length(), np.length() - serve_folder.length());
|
String nnp = np.substr(serve_folder.length(), np.length() - serve_folder.length());
|
||||||
|
|
||||||
@ -168,11 +166,7 @@ void BrowsableFolderServeWebPage::render_dir_page(const String &dir_uri, const V
|
|||||||
}
|
}
|
||||||
b.cdiv();
|
b.cdiv();
|
||||||
|
|
||||||
BFSNEntry e;
|
_folder_indexes[dir_uri] = b.result;
|
||||||
e.uri = dir_uri;
|
|
||||||
e.data = b.result;
|
|
||||||
|
|
||||||
_folder_indexes.push_back(e);
|
|
||||||
|
|
||||||
if (dir_uri == "/") {
|
if (dir_uri == "/") {
|
||||||
_index = b.result;
|
_index = b.result;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "core/containers/vector.h"
|
#include "core/containers/hash_map.h"
|
||||||
#include "core/string/ustring.h"
|
#include "core/string/ustring.h"
|
||||||
|
|
||||||
#include "folder_serve_web_page.h"
|
#include "folder_serve_web_page.h"
|
||||||
@ -76,12 +76,7 @@ protected:
|
|||||||
|
|
||||||
bool _should_render_menu;
|
bool _should_render_menu;
|
||||||
|
|
||||||
struct BFSNEntry {
|
HashMap<String, String> _folder_indexes;
|
||||||
String uri;
|
|
||||||
String data;
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector<BFSNEntry> _folder_indexes;
|
|
||||||
String _index;
|
String _index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user