mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-17 04:39:34 +00:00
Core: Bring over some file related Switch changes.
Reducing the distance from the Switch port code.
This commit is contained in:
parent
051a84e9bd
commit
cb1b7b1e43
@ -64,11 +64,7 @@ ConsoleListener::ConsoleListener() : bHidden(true)
|
||||
logPending = new char[LOG_PENDING_MAX];
|
||||
}
|
||||
++refCount;
|
||||
#elif defined(ANDROID)
|
||||
bUseColor = false;
|
||||
#elif defined(IOS)
|
||||
bUseColor = false;
|
||||
#elif PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(SWITCH)
|
||||
#elif PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(SWITCH)
|
||||
bUseColor = false;
|
||||
#elif defined(_MSC_VER)
|
||||
bUseColor = false;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <mutex>
|
||||
#include <cstring>
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include "file/file_util.h"
|
||||
#include "file/free.h"
|
||||
#include "util/text/utf8.h"
|
||||
@ -29,6 +30,11 @@
|
||||
#include "Core/FileLoaders/DiskCachingFileLoader.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#if PPSSPP_PLATFORM(SWITCH)
|
||||
// Far from optimal, but I guess it works...
|
||||
#define fseeko fseek
|
||||
#endif
|
||||
|
||||
static const char *CACHEFILE_MAGIC = "ppssppDC";
|
||||
static const s64 SAFETY_FREE_DISK_SPACE = 768 * 1024 * 1024; // 768 MB
|
||||
// Aim to allow this many files cached at once.
|
||||
|
@ -117,7 +117,12 @@ std::string LocalFileLoader::Path() const {
|
||||
}
|
||||
|
||||
size_t LocalFileLoader::ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags) {
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
#if PPSSPP_PLATFORM(SWITCH)
|
||||
// Toolchain has no fancy IO API. We must lock.
|
||||
std::lock_guard<std::mutex> guard(readLock_);
|
||||
lseek(fd_, absolutePos, SEEK_SET);
|
||||
return read(fd_, data, bytes * count) / bytes;
|
||||
#elif PPSSPP_PLATFORM(ANDROID)
|
||||
// pread64 doesn't appear to actually be 64-bit safe, though such ISOs are uncommon. See #10862.
|
||||
if (absolutePos <= 0x7FFFFFFF) {
|
||||
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS < 64
|
||||
|
@ -442,7 +442,8 @@ void DirectoryFileHandle::Close()
|
||||
if (SetEndOfFile(hFile) == 0) {
|
||||
ERROR_LOG_REPORT(FILESYS, "Failed to truncate file.");
|
||||
}
|
||||
#else
|
||||
#elif !PPSSPP_PLATFORM(SWITCH)
|
||||
// Note: it's not great that Switch cannot truncate appropriately...
|
||||
if (ftruncate(hFile, (off_t)needsTrunc_) != 0) {
|
||||
ERROR_LOG_REPORT(FILESYS, "Failed to truncate file.");
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ void InitSysDirectories() {
|
||||
INFO_LOG(COMMON, "Memstick directory not present, creating at '%s'", g_Config.memStickDirectory.c_str());
|
||||
}
|
||||
|
||||
const std::string testFile = g_Config.memStickDirectory + "/_writable_test.$$$";
|
||||
const std::string testFile = g_Config.memStickDirectory + "_writable_test.$$$";
|
||||
|
||||
// If any directory is read-only, fall back to the Documents directory.
|
||||
// We're screwed anyway if we can't write to Documents, or can't detect it.
|
||||
|
@ -55,7 +55,7 @@ std::string GameManager::GetTempFilename() const {
|
||||
GetTempFileName(tempPath, L"PSP", 1, buffer);
|
||||
return ConvertWStringToUTF8(buffer);
|
||||
#else
|
||||
return g_Config.memStickDirectory + "/ppsspp.dl";
|
||||
return g_Config.memStickDirectory + "ppsspp.dl";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL/SDLJoystick.h"
|
||||
SDLJoystick *joystick = NULL;
|
||||
@ -196,7 +197,11 @@ void OpenDirectory(const char *path) {
|
||||
}
|
||||
|
||||
void LaunchBrowser(const char *url) {
|
||||
#if defined(MOBILE_DEVICE)
|
||||
#if PPSSPP_PLATFORM(SWITCH)
|
||||
WebWifiConfig conf;
|
||||
webWifiCreate(&conf, NULL, url, 0, 0);
|
||||
webWifiShow(&conf, NULL);
|
||||
#elif defined(MOBILE_DEVICE)
|
||||
ILOG("Would have gone to %s but LaunchBrowser is not implemented on this platform", url);
|
||||
#elif defined(_WIN32)
|
||||
std::wstring wurl = ConvertUTF8ToWString(url);
|
||||
@ -214,7 +219,11 @@ void LaunchBrowser(const char *url) {
|
||||
}
|
||||
|
||||
void LaunchMarket(const char *url) {
|
||||
#if defined(MOBILE_DEVICE)
|
||||
#if PPSSPP_PLATFORM(SWITCH)
|
||||
WebWifiConfig conf;
|
||||
webWifiCreate(&conf, NULL, url, 0, 0);
|
||||
webWifiShow(&conf, NULL);
|
||||
#elif defined(MOBILE_DEVICE)
|
||||
ILOG("Would have gone to %s but LaunchMarket is not implemented on this platform", url);
|
||||
#elif defined(_WIN32)
|
||||
std::wstring wurl = ConvertUTF8ToWString(url);
|
||||
@ -258,6 +267,8 @@ std::string System_GetProperty(SystemProperty prop) {
|
||||
return "SDL:Linux";
|
||||
#elif __APPLE__
|
||||
return "SDL:macOS";
|
||||
#elif PPSSPP_PLATFORM(SWITCH)
|
||||
return "SDL:Horizon";
|
||||
#else
|
||||
return "SDL:";
|
||||
#endif
|
||||
|
@ -511,7 +511,7 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
|
||||
}
|
||||
|
||||
UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
|
||||
#ifdef __ANDROID__
|
||||
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
|
||||
SetPath(g_Config.memStickDirectory);
|
||||
#elif defined(USING_QT_UI) || defined(USING_WIN_UI)
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) {
|
||||
|
@ -459,7 +459,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
VFSRegister("", new DirectoryAssetReader("/usr/share/ppsspp/assets/"));
|
||||
#endif
|
||||
#if PPSSPP_PLATFORM(SWITCH)
|
||||
std::string assetPath = savegame_dir + "assets/";
|
||||
std::string assetPath = user_data_path + "assets/";
|
||||
VFSRegister("", new DirectoryAssetReader(assetPath.c_str()));
|
||||
#else
|
||||
VFSRegister("", new DirectoryAssetReader("assets/"));
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
#else
|
||||
#include <strings.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
@ -29,6 +30,13 @@
|
||||
#define stat64 stat
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
// Far from optimal, but I guess it works...
|
||||
#define fseeko fseek
|
||||
#define ftello ftell
|
||||
#define fileno
|
||||
#endif // HAVE_LIBNX
|
||||
|
||||
FILE *openCFile(const std::string &filename, const char *mode)
|
||||
{
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user