Permalink
Browse files

Merge pull request #11454 from unknownbrackets/remote-iso

http: Allow pbp and ppdmp files too
  • Loading branch information...
hrydgard committed Oct 8, 2018
2 parents a0b019d + 02b418e commit 1b8bf31e898984921e976b6956886cdda875e0f0
Showing with 38 additions and 27 deletions.
  1. +18 −1 Core/WebServer.cpp
  2. +2 −0 Core/WebServer.h
  3. +18 −26 UI/RemoteISOScreen.cpp
View
@@ -106,6 +106,23 @@ static void RegisterServer(int port) {
}
}
bool RemoteISOFileSupported(const std::string &filename) {
// Disc-like files.
if (endsWithNoCase(filename, ".cso") || endsWithNoCase(filename, ".iso")) {
return true;
}
// May work - but won't have supporting files.
if (endsWithNoCase(filename, ".pbp")) {
return true;
}
// Debugging files.
if (endsWithNoCase(filename, ".ppdmp")) {
return true;
}
return false;
}
static void RegisterDiscHandlers(http::Server *http, std::unordered_map<std::string, std::string> *paths) {
for (std::string filename : g_Config.recentIsos) {
#ifdef _WIN32
@@ -118,7 +135,7 @@ static void RegisterDiscHandlers(http::Server *http, std::unordered_map<std::str
// Let's not serve directories, since they won't work. Only single files.
// Maybe can do PBPs and other files later. Would be neat to stream virtual disc filesystems.
if (endsWithNoCase(basename, ".cso") || endsWithNoCase(basename, ".iso")) {
if (RemoteISOFileSupported(basename)) {
(*paths)[ReplaceAll(basename, " ", "%20")] = filename;
}
}
View
@@ -26,3 +26,5 @@ bool StartWebServer(WebServerFlags flags);
bool StopWebServer(WebServerFlags flags);
bool WebServerStopping(WebServerFlags flags);
bool WebServerStopped(WebServerFlags flags);
bool RemoteISOFileSupported(const std::string &filename);
View
@@ -121,22 +121,22 @@ static bool LoadGameList(const std::string &host, int port, std::vector<std::str
Buffer result;
int code = 500;
std::vector<std::string> responseHeaders;
std::string subdir ="/";
std::string subdir = "/";
size_t offset;
if (g_Config.bRemoteISOManual) {
subdir = g_Config.sRemoteISOSubdir;
offset=subdir.find_last_of("/");
if (offset != subdir.length() - 1 && offset != subdir.npos) {
//truncate everything after last /
// Truncate everything after last /
subdir.erase(offset + 1);
}
}
// Start by requesting the list of games from the server.
if (http.Resolve(host.c_str(), port)) {
if (http.Connect(2, 20.0, &scanCancelled)) {
code = http.GET(subdir.c_str(), &result,responseHeaders);
code = http.GET(subdir.c_str(), &result, responseHeaders);
http.Disconnect();
}
}
@@ -165,37 +165,29 @@ static bool LoadGameList(const std::string &host, int port, std::vector<std::str
bool parseText = startsWithNoCase(contentType, "text/plain");
if (parseText) {
//ppsspp server
// Plain text format - easy.
SplitString(listing, '\n', items);
for (const std::string &item : items) {
if (!endsWithNoCase(item, ".cso") && !endsWithNoCase(item, ".iso") && !endsWithNoCase(item, ".pbp")) {
continue;
}
char temp[1024] = {};
snprintf(temp, sizeof(temp) - 1, "http://%s:%d%s", host.c_str(), port, item.c_str());
games.push_back(temp);
}
subdir.clear();
} else if (parseHtml) {
//other webserver
// Try to extract from an automatic webserver directory listing...
GetQuotedStrings(listing, items);
for (const std::string &item : items) {
if (!endsWithNoCase(item, ".cso") && !endsWithNoCase(item, ".iso") && !endsWithNoCase(item, ".pbp")) {
continue;
}
char temp[1024] = {};
snprintf(temp, sizeof(temp) - 1, "http://%s:%d%s%s", host.c_str(), port, subdir.c_str(),item.c_str());
games.push_back(temp);
}
} else {
ERROR_LOG(FILESYS, "Unsupported Content-Type: %s", contentType.c_str());
return false;
}
//save for next time unless manual is true
if (!games.empty() && !g_Config.bRemoteISOManual){
for (const std::string &item : items) {
if (!RemoteISOFileSupported(item)) {
continue;
}
char temp[1024] = {};
snprintf(temp, sizeof(temp) - 1, "http://%s:%d%s%s", host.c_str(), port, subdir.c_str(), item.c_str());
games.push_back(temp);
}
// Save for next time unless manual is true
if (!games.empty() && !g_Config.bRemoteISOManual) {
g_Config.sLastRemoteISOServer = host;
g_Config.iLastRemoteISOPort = port;
}

0 comments on commit 1b8bf31

Please sign in to comment.