mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
http: Allow pbp and ppdmp files too.
Also cleanup a bit.
This commit is contained in:
1 parent
486707b43a
commit
02b418e711
3 files changed
+38
-27
No files matched your search
+18
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
+18
-26
@@ -121,14 +121,14 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ static bool LoadGameList(const std::string &host, int port, std::vector<std::str
|
||||
// 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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user