mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
http: Show recent games in same order.
Rather than sorting alphabetically by filename.
This commit is contained in:
parent
2e5065a6f5
commit
b2005f87e6
1 changed files with 37 additions and 14 deletions
|
@ -155,8 +155,7 @@ static std::string LocalFromRemotePath(const std::string &path) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DiscHandler(const http::Request &request) {
|
static void DiscHandler(const http::Request &request, const std::string &filename) {
|
||||||
std::string filename = LocalFromRemotePath(request.resource());
|
|
||||||
s64 sz = File::GetFileSize(filename);
|
s64 sz = File::GetFileSize(filename);
|
||||||
|
|
||||||
std::string range;
|
std::string range;
|
||||||
|
@ -208,26 +207,50 @@ static void DiscHandler(const http::Request &request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RegisterDiscHandlers(http::Server *http) {
|
static void HandleListing(const http::Request &request) {
|
||||||
for (const std::string &filename : g_Config.recentIsos) {
|
request.WriteHttpResponseHeader("1.0", 200, -1, "text/plain");
|
||||||
std::string basename = RemotePathForRecent(filename);
|
request.Out()->Printf("/\n");
|
||||||
if (!basename.empty()) {
|
if (serverFlags & (int)WebServerFlags::DISCS) {
|
||||||
http->RegisterHandler(basename.c_str(), &DiscHandler);
|
// List the current discs in their recent order.
|
||||||
|
for (const std::string &filename : g_Config.recentIsos) {
|
||||||
|
std::string basename = RemotePathForRecent(filename);
|
||||||
|
if (!basename.empty()) {
|
||||||
|
request.Out()->Printf("%s\n", basename.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (serverFlags & (int)WebServerFlags::DEBUGGER) {
|
||||||
|
request.Out()->Printf("/debugger\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void HandleFallback(const http::Request &request) {
|
||||||
|
std::string filename = LocalFromRemotePath(request.resource());
|
||||||
|
if (!filename.empty()) {
|
||||||
|
DiscHandler(request, filename);
|
||||||
|
} else {
|
||||||
|
static const std::string payload = "404 not found\r\n";
|
||||||
|
request.WriteHttpResponseHeader("1.0", 404, (int)payload.size(), "text/plain");
|
||||||
|
request.Out()->Push(payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ForwardDebuggerRequest(const http::Request &request) {
|
||||||
|
if (serverFlags & (int)WebServerFlags::DEBUGGER) {
|
||||||
|
HandleDebuggerRequest(request);
|
||||||
|
} else {
|
||||||
|
HandleFallback(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ExecuteWebServer() {
|
static void ExecuteWebServer() {
|
||||||
setCurrentThreadName("HTTPServer");
|
setCurrentThreadName("HTTPServer");
|
||||||
|
|
||||||
auto http = new http::Server(new threading::NewThreadExecutor());
|
auto http = new http::Server(new threading::NewThreadExecutor());
|
||||||
|
http->RegisterHandler("/", &HandleListing);
|
||||||
if (serverFlags & (int)WebServerFlags::DISCS) {
|
// This lists all the (current) recent ISOs.
|
||||||
RegisterDiscHandlers(http);
|
http->SetFallbackHandler(&HandleFallback);
|
||||||
}
|
http->RegisterHandler("/debugger", &ForwardDebuggerRequest);
|
||||||
if (serverFlags & (int)WebServerFlags::DEBUGGER) {
|
|
||||||
http->RegisterHandler("/debugger", &HandleDebuggerRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!http->Listen(g_Config.iRemoteISOPort)) {
|
if (!http->Listen(g_Config.iRemoteISOPort)) {
|
||||||
if (!http->Listen(0)) {
|
if (!http->Listen(0)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue