mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-08-31 09:45:24 +02:00
Add a setting (defaulting to false) for enabling file handler plugins
This commit is contained in:
@@ -28,6 +28,16 @@
|
||||
#include "Core/HLE/sceKernel.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Core/Config.h"
|
||||
|
||||
#if PLATFORM_SUPPORTS_FILE_HANDLER_PLUGINS
|
||||
static bool EnableFileHandlerPlugins() {
|
||||
return g_Config.bEnableFileHandlerPlugins;
|
||||
}
|
||||
#else
|
||||
// Completely disable file handler plugins. Just not allowed to do things like this on mobile.
|
||||
constexpr bool EnableFileHandlerPlugins() { return false; }
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Common/CommonWindows.h"
|
||||
@@ -40,7 +50,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#if !PPSSPP_PLATFORM(SWITCH)
|
||||
#if PLATFORM_SUPPORTS_FILE_HANDLER_PLUGINS
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -111,16 +121,23 @@ void VirtualDiscFileSystem::LoadFileListIndex() {
|
||||
size_t handler_pos = line.find(':', filename_pos);
|
||||
if (handler_pos != line.npos) {
|
||||
entry.fileName = line.substr(filename_pos, handler_pos - filename_pos);
|
||||
#if PLATFORM_SUPPORTS_FILE_HANDLER_PLUGINS
|
||||
if (EnableFileHandlerPlugins()) {
|
||||
std::string handler = line.substr(handler_pos + 1);
|
||||
size_t trunc = handler.find_last_not_of("\r\n");
|
||||
if (trunc != handler.npos && trunc != handler.size())
|
||||
handler.resize(trunc + 1);
|
||||
|
||||
std::string handler = line.substr(handler_pos + 1);
|
||||
size_t trunc = handler.find_last_not_of("\r\n");
|
||||
if (trunc != handler.npos && trunc != handler.size())
|
||||
handler.resize(trunc + 1);
|
||||
|
||||
if (handlers.find(handler) == handlers.end())
|
||||
handlers[handler] = new Handler(handler.c_str(), this);
|
||||
if (handlers[handler]->IsValid())
|
||||
entry.handler = handlers[handler];
|
||||
if (handlers.find(handler) == handlers.end())
|
||||
handlers[handler] = new Handler(handler.c_str(), this);
|
||||
if (handlers[handler]->IsValid())
|
||||
entry.handler = handlers[handler];
|
||||
} else {
|
||||
ERROR_LOG(Log::FileSystem, "File handler plugins are disabled, ignoring handler %s for file %s", line.substr(handler_pos + 1).c_str(), entry.fileName.c_str());
|
||||
}
|
||||
#else
|
||||
ERROR_LOG(Log::FileSystem, "File handler plugins are not supported on this platform, ignoring handler %s for file %s", line.substr(handler_pos + 1).c_str(), entry.fileName.c_str());
|
||||
#endif
|
||||
} else {
|
||||
entry.fileName = line.substr(filename_pos);
|
||||
}
|
||||
@@ -821,7 +838,7 @@ void VirtualDiscFileSystem::HandlerLogger(void *arg, HandlerHandle handle, LogLe
|
||||
|
||||
VirtualDiscFileSystem::Handler::Handler(const char *filename, VirtualDiscFileSystem *const sys)
|
||||
: sys_(sys) {
|
||||
#if !PPSSPP_PLATFORM(SWITCH)
|
||||
#if PLATFORM_SUPPORTS_FILE_HANDLER_PLUGINS
|
||||
#ifdef _WIN32
|
||||
#if PPSSPP_PLATFORM(UWP)
|
||||
#define dlopen(name, ignore) (void *)LoadPackagedLibrary(ConvertUTF8ToWString(name).c_str(), 0)
|
||||
@@ -875,7 +892,7 @@ VirtualDiscFileSystem::Handler::~Handler() {
|
||||
else
|
||||
Shutdown();
|
||||
|
||||
#if !PPSSPP_PLATFORM(UWP) && !PPSSPP_PLATFORM(SWITCH)
|
||||
#if PLATFORM_SUPPORTS_FILE_HANDLER_PLUGINS
|
||||
#ifdef _WIN32
|
||||
FreeLibrary((HMODULE)library);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user