Renaming and file splitting

This commit is contained in:
Henrik Rydgård 2023-03-06 15:30:39 +01:00
parent 54af240013
commit 53172eff63
23 changed files with 169 additions and 139 deletions

View File

@ -588,8 +588,10 @@ add_library(Common STATIC
Common/Data/Random/Rng.h Common/Data/Random/Rng.h
Common/File/VFS/VFS.h Common/File/VFS/VFS.h
Common/File/VFS/VFS.cpp Common/File/VFS/VFS.cpp
Common/File/VFS/AssetReader.cpp Common/File/VFS/ZipFileReader.cpp
Common/File/VFS/AssetReader.h Common/File/VFS/ZipFileReader.h
Common/File/VFS/DirectoryReader.cpp
Common/File/VFS/DirectoryReader.h
Common/File/AndroidStorage.h Common/File/AndroidStorage.h
Common/File/AndroidStorage.cpp Common/File/AndroidStorage.cpp
Common/File/DiskFree.h Common/File/DiskFree.h
@ -1150,7 +1152,7 @@ elseif(IOS AND NOT LIBRETRO)
UI/DarwinFileSystemServices.h UI/DarwinFileSystemServices.h
Common/Battery/AppleBatteryClient.m Common/Battery/AppleBatteryClient.m
) )
set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework MediaPlayer -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework UIKit -framework GLKit -framework OpenAL -framework AVFoundation -framework CoreLocation -framework CoreVideo -framework CoreMedia -framework CoreServices" ) set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework MediaPlayer -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework UIKit -framework GLKit -framework OpenAL -framework AVFoundation -framework CoreLocation -framework CoreVideo -framework CoreMedia -framework CoreServices" )
if(EXISTS "${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks/GameController.framework") if(EXISTS "${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks/GameController.framework")
set(nativeExtraLibs ${nativeExtraLibs} "-weak_framework GameController") set(nativeExtraLibs ${nativeExtraLibs} "-weak_framework GameController")

View File

@ -425,8 +425,9 @@
<ClInclude Include="File\FileUtil.h" /> <ClInclude Include="File\FileUtil.h" />
<ClInclude Include="File\Path.h" /> <ClInclude Include="File\Path.h" />
<ClInclude Include="File\PathBrowser.h" /> <ClInclude Include="File\PathBrowser.h" />
<ClInclude Include="File\VFS\DirectoryReader.h" />
<ClInclude Include="File\VFS\VFS.h" /> <ClInclude Include="File\VFS\VFS.h" />
<ClInclude Include="File\VFS\AssetReader.h" /> <ClInclude Include="File\VFS\ZipFileReader.h" />
<ClInclude Include="GPU\D3D11\D3D11Loader.h" /> <ClInclude Include="GPU\D3D11\D3D11Loader.h" />
<ClInclude Include="GPU\D3D9\D3DCompilerLoader.h" /> <ClInclude Include="GPU\D3D9\D3DCompilerLoader.h" />
<ClInclude Include="GPU\D3D9\D3D9ShaderCompiler.h" /> <ClInclude Include="GPU\D3D9\D3D9ShaderCompiler.h" />
@ -861,8 +862,9 @@
<ClCompile Include="File\FileUtil.cpp" /> <ClCompile Include="File\FileUtil.cpp" />
<ClCompile Include="File\Path.cpp" /> <ClCompile Include="File\Path.cpp" />
<ClCompile Include="File\PathBrowser.cpp" /> <ClCompile Include="File\PathBrowser.cpp" />
<ClCompile Include="File\VFS\DirectoryReader.cpp" />
<ClCompile Include="File\VFS\VFS.cpp" /> <ClCompile Include="File\VFS\VFS.cpp" />
<ClCompile Include="File\VFS\AssetReader.cpp" /> <ClCompile Include="File\VFS\ZipFileReader.cpp" />
<ClCompile Include="GPU\D3D11\D3D11Loader.cpp" /> <ClCompile Include="GPU\D3D11\D3D11Loader.cpp" />
<ClCompile Include="GPU\D3D11\thin3d_d3d11.cpp" /> <ClCompile Include="GPU\D3D11\thin3d_d3d11.cpp" />
<ClCompile Include="GPU\D3D9\D3DCompilerLoader.cpp" /> <ClCompile Include="GPU\D3D9\D3DCompilerLoader.cpp" />

View File

@ -176,9 +176,6 @@
<ClInclude Include="File\VFS\VFS.h"> <ClInclude Include="File\VFS\VFS.h">
<Filter>File\VFS</Filter> <Filter>File\VFS</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="File\VFS\AssetReader.h">
<Filter>File\VFS</Filter>
</ClInclude>
<ClInclude Include="Data\Format\IniFile.h"> <ClInclude Include="Data\Format\IniFile.h">
<Filter>Data\Format</Filter> <Filter>Data\Format</Filter>
</ClInclude> </ClInclude>
@ -467,6 +464,12 @@
<ClInclude Include="GPU\OpenGL\GLFrameData.h"> <ClInclude Include="GPU\OpenGL\GLFrameData.h">
<Filter>GPU\OpenGL</Filter> <Filter>GPU\OpenGL</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="File\VFS\DirectoryReader.h">
<Filter>File\VFS</Filter>
</ClInclude>
<ClInclude Include="File\VFS\ZipFileReader.h">
<Filter>File\VFS</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="ABI.cpp" /> <ClCompile Include="ABI.cpp" />
@ -628,9 +631,6 @@
<ClCompile Include="File\VFS\VFS.cpp"> <ClCompile Include="File\VFS\VFS.cpp">
<Filter>File\VFS</Filter> <Filter>File\VFS</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="File\VFS\AssetReader.cpp">
<Filter>File\VFS</Filter>
</ClCompile>
<ClCompile Include="Data\Format\IniFile.cpp"> <ClCompile Include="Data\Format\IniFile.cpp">
<Filter>Data\Format</Filter> <Filter>Data\Format</Filter>
</ClCompile> </ClCompile>
@ -884,6 +884,12 @@
<ClCompile Include="GPU\OpenGL\GLFrameData.cpp"> <ClCompile Include="GPU\OpenGL\GLFrameData.cpp">
<Filter>GPU\OpenGL</Filter> <Filter>GPU\OpenGL</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="File\VFS\DirectoryReader.cpp">
<Filter>File\VFS</Filter>
</ClCompile>
<ClCompile Include="File\VFS\ZipFileReader.cpp">
<Filter>File\VFS</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="Crypto"> <Filter Include="Crypto">

View File

@ -0,0 +1,31 @@
#include "Common/Common.h"
#include "Common/Log.h"
#include "Common/File/VFS/DirectoryReader.h"
DirectoryReader::DirectoryReader(const Path &path) {
path_ = path;
}
uint8_t *DirectoryReader::ReadFile(const char *path, size_t *size) {
Path new_path = Path(path).StartsWith(path_) ? Path(path) : path_ / path;
return File::ReadLocalFile(new_path, size);
}
bool DirectoryReader::GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = nullptr) {
Path new_path = Path(path).StartsWith(path_) ? Path(path) : path_ / path;
File::FileInfo info;
if (!File::GetFileInfo(new_path, &info))
return false;
if (info.isDirectory) {
File::GetFilesInDir(new_path, listing, filter);
return true;
}
return false;
}
bool DirectoryReader::GetFileInfo(const char *path, File::FileInfo *info) {
Path new_path = Path(path).StartsWith(path_) ? Path(path) : path_ / path;
return File::GetFileInfo(new_path, info);
}

View File

@ -0,0 +1,21 @@
#pragma once
#include "Common/File/VFS/VFS.h"
#include "Common/File/FileUtil.h"
#include "Common/File/Path.h"
class DirectoryReader : public VFSBackend {
public:
explicit DirectoryReader(const Path &path);
// use delete[] on the returned value.
uint8_t *ReadFile(const char *path, size_t *size) override;
bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter) override;
bool GetFileInfo(const char *path, File::FileInfo *info) override;
std::string toString() const override {
return path_.ToString();
}
private:
Path path_;
};

View File

@ -1,11 +1,13 @@
#include <cstring>
#include "Common/Log.h" #include "Common/Log.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/FileUtil.h"
#include "Common/File/AndroidStorage.h" #include "Common/File/AndroidStorage.h"
VFS g_VFS; VFS g_VFS;
void VFS::Register(const char *prefix, AssetReader *reader) { void VFS::Register(const char *prefix, VFSBackend *reader) {
entries_.push_back(VFSEntry{ prefix, reader }); entries_.push_back(VFSEntry{ prefix, reader });
DEBUG_LOG(IO, "Registered VFS for prefix %s: %s", prefix, reader->toString().c_str()); DEBUG_LOG(IO, "Registered VFS for prefix %s: %s", prefix, reader->toString().c_str());
} }
@ -45,7 +47,7 @@ uint8_t *VFS::ReadFile(const char *filename, size_t *size) {
if (0 == memcmp(filename, entry.prefix, prefix_len)) { if (0 == memcmp(filename, entry.prefix, prefix_len)) {
fileSystemFound = true; fileSystemFound = true;
// INFO_LOG(IO, "Prefix match: %s (%s) -> %s", entries[i].prefix, filename, filename + prefix_len); // INFO_LOG(IO, "Prefix match: %s (%s) -> %s", entries[i].prefix, filename, filename + prefix_len);
uint8_t *data = entry.reader->ReadAsset(filename + prefix_len, size); uint8_t *data = entry.reader->ReadFile(filename + prefix_len, size);
if (data) if (data)
return data; return data;
else else

View File

@ -14,11 +14,11 @@
// on the system level, like loading assets, and maybe texture packs. Also, as mentioned, // on the system level, like loading assets, and maybe texture packs. Also, as mentioned,
// this one is read-only, so a bit smaller and simpler. // this one is read-only, so a bit smaller and simpler.
class AssetReader { class VFSBackend {
public: public:
virtual ~AssetReader() {} virtual ~VFSBackend() {}
// use delete[] to release the returned memory. // use delete[] to release the returned memory.
virtual uint8_t *ReadAsset(const char *path, size_t *size) = 0; virtual uint8_t *ReadFile(const char *path, size_t *size) = 0;
// Filter support is optional but nice to have // Filter support is optional but nice to have
virtual bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = 0) = 0; virtual bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = 0) = 0;
@ -29,7 +29,7 @@ public:
class VFS { class VFS {
public: public:
~VFS() { Clear(); } ~VFS() { Clear(); }
void Register(const char *prefix, AssetReader *reader); void Register(const char *prefix, VFSBackend *reader);
void Clear(); void Clear();
// Use delete [] to release the returned memory. // Use delete [] to release the returned memory.
@ -42,7 +42,7 @@ public:
private: private:
struct VFSEntry { struct VFSEntry {
const char *prefix; const char *prefix;
AssetReader *reader; VFSBackend *reader;
}; };
std::vector<VFSEntry> entries_; std::vector<VFSEntry> entries_;
}; };

View File

@ -1,7 +1,8 @@
#include <algorithm> #include <algorithm>
#include <ctype.h> #include <ctype.h>
#include <set> #include <set>
#include <stdio.h> #include <cstdio>
#include <cstring>
#ifdef SHARED_LIBZIP #ifdef SHARED_LIBZIP
#include <zip.h> #include <zip.h>
@ -11,9 +12,9 @@
#include "Common/Common.h" #include "Common/Common.h"
#include "Common/Log.h" #include "Common/Log.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/ZipFileReader.h"
uint8_t *ReadFromZip(zip *archive, const char* filename, size_t *size) { static uint8_t *ReadFromZip(zip *archive, const char* filename, size_t *size) {
// Figure out the file size first. // Figure out the file size first.
struct zip_stat zstat; struct zip_stat zstat;
zip_file *file = zip_fopen(archive, filename, ZIP_FL_NOCASE|ZIP_FL_UNCHANGED); zip_file *file = zip_fopen(archive, filename, ZIP_FL_NOCASE|ZIP_FL_UNCHANGED);
@ -32,7 +33,7 @@ uint8_t *ReadFromZip(zip *archive, const char* filename, size_t *size) {
return contents; return contents;
} }
ZipAssetReader::ZipAssetReader(const char *zip_file, const char *in_zip_path) { ZipFileReader::ZipFileReader(const char *zip_file, const char *in_zip_path) {
zip_file_ = zip_open(zip_file, 0, NULL); zip_file_ = zip_open(zip_file, 0, NULL);
strcpy(in_zip_path_, in_zip_path); strcpy(in_zip_path_, in_zip_path);
if (!zip_file_) { if (!zip_file_) {
@ -50,24 +51,22 @@ ZipAssetReader::ZipAssetReader(const char *zip_file, const char *in_zip_path) {
} }
} }
ZipAssetReader::~ZipAssetReader() { ZipFileReader::~ZipFileReader() {
std::lock_guard<std::mutex> guard(lock_); std::lock_guard<std::mutex> guard(lock_);
zip_close(zip_file_); zip_close(zip_file_);
} }
uint8_t *ZipAssetReader::ReadAsset(const char *path, size_t *size) { uint8_t *ZipFileReader::ReadFile(const char *path, size_t *size) {
char temp_path[1024]; char temp_path[2048];
strcpy(temp_path, in_zip_path_); snprintf(temp_path, sizeof(temp_path), "%s%s", in_zip_path_, path);
strcat(temp_path, path);
std::lock_guard<std::mutex> guard(lock_); std::lock_guard<std::mutex> guard(lock_);
return ReadFromZip(zip_file_, temp_path, size); return ReadFromZip(zip_file_, temp_path, size);
} }
bool ZipAssetReader::GetFileListing(const char *orig_path, std::vector<File::FileInfo> *listing, const char *filter = 0) { bool ZipFileReader::GetFileListing(const char *orig_path, std::vector<File::FileInfo> *listing, const char *filter = 0) {
char path[1024]; char path[2048];
strcpy(path, in_zip_path_); snprintf(path, sizeof(path), "%s%s", in_zip_path_, orig_path);
strcat(path, orig_path);
std::set<std::string> filters; std::set<std::string> filters;
std::string tmp; std::string tmp;
@ -123,7 +122,7 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vector<File::Fil
return true; return true;
} }
void ZipAssetReader::GetZipListings(const char *path, std::set<std::string> &files, std::set<std::string> &directories) { void ZipFileReader::GetZipListings(const char *path, std::set<std::string> &files, std::set<std::string> &directories) {
size_t pathlen = strlen(path); size_t pathlen = strlen(path);
if (path[pathlen - 1] == '/') if (path[pathlen - 1] == '/')
pathlen--; pathlen--;
@ -149,7 +148,7 @@ void ZipAssetReader::GetZipListings(const char *path, std::set<std::string> &fil
} }
} }
bool ZipAssetReader::GetFileInfo(const char *path, File::FileInfo *info) { bool ZipFileReader::GetFileInfo(const char *path, File::FileInfo *info) {
struct zip_stat zstat; struct zip_stat zstat;
char temp_path[1024]; char temp_path[1024];
snprintf(temp_path, sizeof(temp_path), "%s%s", in_zip_path_, path); snprintf(temp_path, sizeof(temp_path), "%s%s", in_zip_path_, path);
@ -168,31 +167,3 @@ bool ZipAssetReader::GetFileInfo(const char *path, File::FileInfo *info) {
info->size = zstat.size; info->size = zstat.size;
return true; return true;
} }
DirectoryAssetReader::DirectoryAssetReader(const Path &path) {
path_ = path;
}
uint8_t *DirectoryAssetReader::ReadAsset(const char *path, size_t *size) {
Path new_path = Path(path).StartsWith(path_) ? Path(path) : path_ / path;
return File::ReadLocalFile(new_path, size);
}
bool DirectoryAssetReader::GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = nullptr) {
Path new_path = Path(path).StartsWith(path_) ? Path(path) : path_ / path;
File::FileInfo info;
if (!File::GetFileInfo(new_path, &info))
return false;
if (info.isDirectory) {
File::GetFilesInDir(new_path, listing, filter);
return true;
}
return false;
}
bool DirectoryAssetReader::GetFileInfo(const char *path, File::FileInfo *info) {
Path new_path = Path(path).StartsWith(path_) ? Path(path) : path_ / path;
return File::GetFileInfo(new_path, info);
}

View File

@ -8,19 +8,18 @@
#include <mutex> #include <mutex>
#include <set> #include <set>
#include <string.h>
#include <string> #include <string>
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/FileUtil.h" #include "Common/File/FileUtil.h"
#include "Common/File/Path.h" #include "Common/File/Path.h"
class ZipAssetReader : public AssetReader { class ZipFileReader : public VFSBackend {
public: public:
ZipAssetReader(const char *zip_file, const char *in_zip_path); ZipFileReader(const char *zip_file, const char *in_zip_path);
~ZipAssetReader(); ~ZipFileReader();
// use delete[] on the returned value. // use delete[] on the returned value.
uint8_t *ReadAsset(const char *path, size_t *size) override; uint8_t *ReadFile(const char *path, size_t *size) override;
bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter) override; bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter) override;
bool GetFileInfo(const char *path, File::FileInfo *info) override; bool GetFileInfo(const char *path, File::FileInfo *info) override;
std::string toString() const override { std::string toString() const override {
@ -34,19 +33,3 @@ private:
std::mutex lock_; std::mutex lock_;
char in_zip_path_[256]; char in_zip_path_[256];
}; };
class DirectoryAssetReader : public AssetReader {
public:
explicit DirectoryAssetReader(const Path &path);
// use delete[]
uint8_t *ReadAsset(const char *path, size_t *size) override;
bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter) override;
bool GetFileInfo(const char *path, File::FileInfo *info) override;
std::string toString() const override {
return path_.ToString();
}
private:
Path path_;
};

View File

@ -25,7 +25,7 @@ QTM_USE_NAMESPACE
#include "Common/System/Display.h" #include "Common/System/Display.h"
#include "Common/TimeUtil.h" #include "Common/TimeUtil.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/DirectoryReader.h"
#include "Common/GPU/OpenGL/GLCommon.h" #include "Common/GPU/OpenGL/GLCommon.h"
#include "Common/GPU/OpenGL/GLFeatures.h" #include "Common/GPU/OpenGL/GLFeatures.h"
#include "Common/Input/InputState.h" #include "Common/Input/InputState.h"
@ -191,4 +191,3 @@ private:
#endif //SDL #endif //SDL
#endif #endif

View File

@ -67,7 +67,8 @@
#include "Common/Profiler/Profiler.h" #include "Common/Profiler/Profiler.h"
#include "Common/Data/Encoding/Utf8.h" #include "Common/Data/Encoding/Utf8.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/ZipFileReader.h"
#include "Common/File/VFS/DirectoryReader.h"
#include "Common/CPUDetect.h" #include "Common/CPUDetect.h"
#include "Common/File/FileUtil.h" #include "Common/File/FileUtil.h"
#include "Common/TimeUtil.h" #include "Common/TimeUtil.h"
@ -467,27 +468,27 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
// We want this to be FIRST. // We want this to be FIRST.
#if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC) #if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC)
// Packed assets are included in app // Packed assets are included in app
g_VFS.Register("", new DirectoryAssetReader(Path(external_dir))); g_VFS.Register("", new DirectoryReader(Path(external_dir)));
#endif #endif
#if defined(ASSETS_DIR) #if defined(ASSETS_DIR)
g_VFS.Register("", new DirectoryAssetReader(Path(ASSETS_DIR))); g_VFS.Register("", new DirectoryReader(Path(ASSETS_DIR)));
#endif #endif
#if !defined(MOBILE_DEVICE) && !defined(_WIN32) && !PPSSPP_PLATFORM(SWITCH) #if !defined(MOBILE_DEVICE) && !defined(_WIN32) && !PPSSPP_PLATFORM(SWITCH)
g_VFS.Register("", new DirectoryAssetReader(File::GetExeDirectory() / "assets")); g_VFS.Register("", new DirectoryReader(File::GetExeDirectory() / "assets"));
g_VFS.Register("", new DirectoryAssetReader(File::GetExeDirectory())); g_VFS.Register("", new DirectoryReader(File::GetExeDirectory()));
g_VFS.Register("", new DirectoryAssetReader(Path("/usr/local/share/ppsspp/assets"))); g_VFS.Register("", new DirectoryReader(Path("/usr/local/share/ppsspp/assets")));
g_VFS.Register("", new DirectoryAssetReader(Path("/usr/local/share/games/ppsspp/assets"))); g_VFS.Register("", new DirectoryReader(Path("/usr/local/share/games/ppsspp/assets")));
g_VFS.Register("", new DirectoryAssetReader(Path("/usr/share/ppsspp/assets"))); g_VFS.Register("", new DirectoryReader(Path("/usr/share/ppsspp/assets")));
g_VFS.Register("", new DirectoryAssetReader(Path("/usr/share/games/ppsspp/assets"))); g_VFS.Register("", new DirectoryReader(Path("/usr/share/games/ppsspp/assets")));
#endif #endif
#if PPSSPP_PLATFORM(SWITCH) #if PPSSPP_PLATFORM(SWITCH)
Path assetPath = Path(user_data_path) / "assets"; Path assetPath = Path(user_data_path) / "assets";
g_VFS.Register("", new DirectoryAssetReader(assetPath)); g_VFS.Register("", new DirectoryReader(assetPath));
#else #else
g_VFS.Register("", new DirectoryAssetReader(Path("assets"))); g_VFS.Register("", new DirectoryReader(Path("assets")));
#endif #endif
g_VFS.Register("", new DirectoryAssetReader(Path(savegame_dir))); g_VFS.Register("", new DirectoryReader(Path(savegame_dir)));
#if (defined(MOBILE_DEVICE) || !defined(USING_QT_UI)) && !PPSSPP_PLATFORM(UWP) #if (defined(MOBILE_DEVICE) || !defined(USING_QT_UI)) && !PPSSPP_PLATFORM(UWP)
if (host == nullptr) { if (host == nullptr) {

View File

@ -306,7 +306,8 @@
<ClInclude Include="..\..\Common\File\FileUtil.h" /> <ClInclude Include="..\..\Common\File\FileUtil.h" />
<ClInclude Include="..\..\Common\File\Path.h" /> <ClInclude Include="..\..\Common\File\Path.h" />
<ClInclude Include="..\..\Common\File\PathBrowser.h" /> <ClInclude Include="..\..\Common\File\PathBrowser.h" />
<ClInclude Include="..\..\Common\File\VFS\AssetReader.h" /> <ClInclude Include="..\..\Common\File\VFS\DirectoryReader.h" />
<ClInclude Include="..\..\Common\File\VFS\ZipFileReader.h" />
<ClInclude Include="..\..\Common\File\VFS\VFS.h" /> <ClInclude Include="..\..\Common\File\VFS\VFS.h" />
<ClInclude Include="..\..\Common\GPU\DataFormat.h" /> <ClInclude Include="..\..\Common\GPU\DataFormat.h" />
<ClInclude Include="..\..\Common\GPU\OpenGL\GLFeatures.h" /> <ClInclude Include="..\..\Common\GPU\OpenGL\GLFeatures.h" />
@ -443,7 +444,8 @@
<ClCompile Include="..\..\Common\File\FileUtil.cpp" /> <ClCompile Include="..\..\Common\File\FileUtil.cpp" />
<ClCompile Include="..\..\Common\File\Path.cpp" /> <ClCompile Include="..\..\Common\File\Path.cpp" />
<ClCompile Include="..\..\Common\File\PathBrowser.cpp" /> <ClCompile Include="..\..\Common\File\PathBrowser.cpp" />
<ClCompile Include="..\..\Common\File\VFS\AssetReader.cpp" /> <ClCompile Include="..\..\Common\File\VFS\DirectoryReader.cpp" />
<ClCompile Include="..\..\Common\File\VFS\ZipFileReader.cpp" />
<ClCompile Include="..\..\Common\File\VFS\VFS.cpp" /> <ClCompile Include="..\..\Common\File\VFS\VFS.cpp" />
<ClCompile Include="..\..\Common\GPU\D3D11\thin3d_d3d11.cpp" /> <ClCompile Include="..\..\Common\GPU\D3D11\thin3d_d3d11.cpp" />
<ClCompile Include="..\..\Common\GPU\OpenGL\GLFeatures.cpp" /> <ClCompile Include="..\..\Common\GPU\OpenGL\GLFeatures.cpp" />

View File

@ -252,7 +252,10 @@
<ClCompile Include="..\..\Common\Data\Format\RIFF.cpp"> <ClCompile Include="..\..\Common\Data\Format\RIFF.cpp">
<Filter>Data\Format</Filter> <Filter>Data\Format</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\Common\File\VFS\AssetReader.cpp"> <ClCompile Include="..\..\Common\File\VFS\DirectoryReader.cpp">
<Filter>File\VFS</Filter>
</ClCompile>
<ClCompile Include="..\..\Common\File\VFS\ZipFileReader.cpp">
<Filter>File\VFS</Filter> <Filter>File\VFS</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\Common\File\VFS\VFS.cpp"> <ClCompile Include="..\..\Common\File\VFS\VFS.cpp">
@ -589,7 +592,10 @@
<ClInclude Include="..\..\Common\Data\Format\RIFF.h"> <ClInclude Include="..\..\Common\Data\Format\RIFF.h">
<Filter>Data\Format</Filter> <Filter>Data\Format</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\Common\File\VFS\AssetReader.h"> <ClInclude Include="..\..\Common\File\VFS\DirectoryReader.h">
<Filter>File\VFS</Filter>
</ClInclude>
<ClInclude Include="..\..\Common\File\VFS\ZipFileReader.h">
<Filter>File\VFS</Filter> <Filter>File\VFS</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\Common\File\VFS\VFS.h"> <ClInclude Include="..\..\Common\File\VFS\VFS.h">

View File

@ -11,7 +11,7 @@
#include "Common/Common.h" #include "Common/Common.h"
#include "Common/Input/InputState.h" #include "Common/Input/InputState.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/DirectoryReader.h"
#include "Common/Thread/ThreadUtil.h" #include "Common/Thread/ThreadUtil.h"
#include "Common/Data/Encoding/Utf8.h" #include "Common/Data/Encoding/Utf8.h"
#include "Common/DirectXHelper.h" #include "Common/DirectXHelper.h"
@ -76,8 +76,8 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
ctx_.reset(new UWPGraphicsContext(deviceResources)); ctx_.reset(new UWPGraphicsContext(deviceResources));
const Path &exePath = File::GetExeDirectory(); const Path &exePath = File::GetExeDirectory();
g_VFS.Register("", new DirectoryAssetReader(exePath / "Content")); g_VFS.Register("", new DirectoryReader(exePath / "Content"));
g_VFS.Register("", new DirectoryAssetReader(exePath)); g_VFS.Register("", new DirectoryReader(exePath));
wchar_t lcCountry[256]; wchar_t lcCountry[256];

View File

@ -36,7 +36,7 @@
#include "Common/System/System.h" #include "Common/System/System.h"
#include "Common/File/FileUtil.h" #include "Common/File/FileUtil.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/DirectoryReader.h"
#include "Common/Data/Text/I18n.h" #include "Common/Data/Text/I18n.h"
#include "Common/Profiler/Profiler.h" #include "Common/Profiler/Profiler.h"
#include "Common/Thread/ThreadUtil.h" #include "Common/Thread/ThreadUtil.h"
@ -583,8 +583,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
#endif #endif
const Path &exePath = File::GetExeDirectory(); const Path &exePath = File::GetExeDirectory();
g_VFS.Register("", new DirectoryAssetReader(exePath / "assets")); g_VFS.Register("", new DirectoryReader(exePath / "assets"));
g_VFS.Register("", new DirectoryAssetReader(exePath)); g_VFS.Register("", new DirectoryReader(exePath));
langRegion = GetDefaultLangRegion(); langRegion = GetDefaultLangRegion();
osName = GetWindowsVersion() + " " + GetWindowsSystemArchitecture(); osName = GetWindowsVersion() + " " + GetWindowsSystemArchitecture();

View File

@ -175,7 +175,8 @@ EXEC_AND_LIB_FILES := \
$(SRC)/Common/Data/Text/WrapText.cpp \ $(SRC)/Common/Data/Text/WrapText.cpp \
$(SRC)/Common/File/AndroidStorage.cpp \ $(SRC)/Common/File/AndroidStorage.cpp \
$(SRC)/Common/File/VFS/VFS.cpp \ $(SRC)/Common/File/VFS/VFS.cpp \
$(SRC)/Common/File/VFS/AssetReader.cpp \ $(SRC)/Common/File/VFS/ZipFileReader.cpp \
$(SRC)/Common/File/VFS/DirectoryReader.cpp \
$(SRC)/Common/File/DiskFree.cpp \ $(SRC)/Common/File/DiskFree.cpp \
$(SRC)/Common/File/Path.cpp \ $(SRC)/Common/File/Path.cpp \
$(SRC)/Common/File/PathBrowser.cpp \ $(SRC)/Common/File/PathBrowser.cpp \

View File

@ -65,7 +65,8 @@ struct JNIEnv {};
#include "Common/File/Path.h" #include "Common/File/Path.h"
#include "Common/File/DirListing.h" #include "Common/File/DirListing.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/DirectoryReader.h"
#include "Common/File/VFS/ZipFileReader.h"
#include "Common/File/AndroidStorage.h" #include "Common/File/AndroidStorage.h"
#include "Common/Input/InputState.h" #include "Common/Input/InputState.h"
#include "Common/Input/KeyCodes.h" #include "Common/Input/KeyCodes.h"
@ -695,7 +696,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
deviceType = jdeviceType; deviceType = jdeviceType;
std::string apkPath = GetJavaString(env, japkpath); std::string apkPath = GetJavaString(env, japkpath);
g_VFS.Register("", new ZipAssetReader(apkPath.c_str(), "assets/")); g_VFS.Register("", new ZipFileReader(apkPath.c_str(), "assets/"));
systemName = GetJavaString(env, jmodel); systemName = GetJavaString(env, jmodel);
langRegion = GetJavaString(env, jlangRegion); langRegion = GetJavaString(env, jlangRegion);

View File

@ -24,7 +24,8 @@
#endif #endif
#include "Common/CPUDetect.h" #include "Common/CPUDetect.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/ZipFileReader.h"
#include "Common/File/VFS/DirectoryReader.h"
#include "Common/File/FileUtil.h" #include "Common/File/FileUtil.h"
#include "Common/GraphicsContext.h" #include "Common/GraphicsContext.h"
#include "Common/TimeUtil.h" #include "Common/TimeUtil.h"
@ -103,7 +104,7 @@ int System_GetPropertyInt(SystemProperty prop) {
return -1; return -1;
} }
float System_GetPropertyFloat(SystemProperty prop) { return -1.0f; } float System_GetPropertyFloat(SystemProperty prop) { return -1.0f; }
bool System_GetPropertyBool(SystemProperty prop) { bool System_GetPropertyBool(SystemProperty prop) {
switch (prop) { switch (prop) {
case SYSPROP_CAN_JIT: case SYSPROP_CAN_JIT:
return true; return true;
@ -482,13 +483,13 @@ int main(int argc, const char* argv[])
#if PPSSPP_PLATFORM(ANDROID) #if PPSSPP_PLATFORM(ANDROID)
// For some reason the debugger installs it with this name? // For some reason the debugger installs it with this name?
if (File::Exists(Path("/data/app/org.ppsspp.ppsspp-2.apk"))) { if (File::Exists(Path("/data/app/org.ppsspp.ppsspp-2.apk"))) {
g_VFS.Register("", new ZipAssetReader("/data/app/org.ppsspp.ppsspp-2.apk", "assets/")); g_VFS.Register("", new ZipFileReader("/data/app/org.ppsspp.ppsspp-2.apk", "assets/"));
} }
if (File::Exists(Path("/data/app/org.ppsspp.ppsspp.apk"))) { if (File::Exists(Path("/data/app/org.ppsspp.ppsspp.apk"))) {
g_VFS.Register("", new ZipAssetReader("/data/app/org.ppsspp.ppsspp.apk", "assets/")); g_VFS.Register("", new ZipFileReader("/data/app/org.ppsspp.ppsspp.apk", "assets/"));
} }
#elif !PPSSPP_PLATFORM(WINDOWS) #elif !PPSSPP_PLATFORM(WINDOWS)
g_VFS.Register("", new DirectoryAssetReader(g_Config.flash0Directory / "..")); g_VFS.Register("", new DirectoryReader(g_Config.flash0Directory / ".."));
#endif #endif
UpdateUIState(UISTATE_INGAME); UpdateUIState(UISTATE_INGAME);

View File

@ -26,7 +26,7 @@
#include "Common/GPU/thin3d_create.h" #include "Common/GPU/thin3d_create.h"
#include "Common/GPU/OpenGL/GLRenderManager.h" #include "Common/GPU/OpenGL/GLRenderManager.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/DirectoryReader.h"
#include "Common/GraphicsContext.h" #include "Common/GraphicsContext.h"
#include "Common/TimeUtil.h" #include "Common/TimeUtil.h"
#include "Core/Config.h" #include "Core/Config.h"
@ -100,9 +100,9 @@ private:
}; };
void SDLHeadlessHost::LoadNativeAssets() { void SDLHeadlessHost::LoadNativeAssets() {
g_VFS.Register("", new DirectoryAssetReader(Path("assets"))); g_VFS.Register("", new DirectoryReader(Path("assets")));
g_VFS.Register("", new DirectoryAssetReader(Path(""))); g_VFS.Register("", new DirectoryReader(Path("")));
g_VFS.Register("", new DirectoryAssetReader(Path(".."))); g_VFS.Register("", new DirectoryReader(Path("..")));
} }
bool GLDummyGraphicsContext::InitFromRenderThread(std::string *errorMessage) { bool GLDummyGraphicsContext::InitFromRenderThread(std::string *errorMessage) {

View File

@ -23,7 +23,7 @@
#include "Common/GPU/OpenGL/GLCommon.h" #include "Common/GPU/OpenGL/GLCommon.h"
#include "Common/GPU/OpenGL/GLFeatures.h" #include "Common/GPU/OpenGL/GLFeatures.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/DirectoryReader.h"
#include "Common/CommonWindows.h" #include "Common/CommonWindows.h"
#include "Common/Log.h" #include "Common/Log.h"
@ -68,11 +68,11 @@ HWND CreateHiddenWindow() {
void WindowsHeadlessHost::LoadNativeAssets() void WindowsHeadlessHost::LoadNativeAssets()
{ {
g_VFS.Register("", new DirectoryAssetReader(Path("assets"))); g_VFS.Register("", new DirectoryReader(Path("assets")));
g_VFS.Register("", new DirectoryAssetReader(Path(""))); g_VFS.Register("", new DirectoryReader(Path("")));
g_VFS.Register("", new DirectoryAssetReader(Path(".."))); g_VFS.Register("", new DirectoryReader(Path("..")));
g_VFS.Register("", new DirectoryAssetReader(Path("../Windows/assets"))); g_VFS.Register("", new DirectoryReader(Path("../Windows/assets")));
g_VFS.Register("", new DirectoryAssetReader(Path("../Windows"))); g_VFS.Register("", new DirectoryReader(Path("../Windows")));
} }
void WindowsHeadlessHost::SendDebugOutput(const std::string &output) void WindowsHeadlessHost::SendDebugOutput(const std::string &output)

View File

@ -17,7 +17,7 @@
#include "Common/System/NativeApp.h" #include "Common/System/NativeApp.h"
#include "Common/TimeUtil.h" #include "Common/TimeUtil.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/DirectoryReader.h"
#include "Common/Input/InputState.h" #include "Common/Input/InputState.h"
#include "Common/Net/Resolve.h" #include "Common/Net/Resolve.h"
#include "Common/UI/Screen.h" #include "Common/UI/Screen.h"
@ -66,9 +66,9 @@
- (void)decodeKeyEvent:(NSInteger *)eventMem { - (void)decodeKeyEvent:(NSInteger *)eventMem {
NSInteger eventType = eventMem[GSEVENT_TYPE]; NSInteger eventType = eventMem[GSEVENT_TYPE];
NSInteger eventScanCode = eventMem[GSEVENTKEY_KEYCODE]; NSInteger eventScanCode = eventMem[GSEVENTKEY_KEYCODE];
//NSLog(@"Got key: %d", (int)eventScanCode); //NSLog(@"Got key: %d", (int)eventScanCode);
if (eventType == GSEVENT_TYPE_KEYUP) { if (eventType == GSEVENT_TYPE_KEYUP) {
struct KeyInput key; struct KeyInput key;
key.flags = KEY_UP; key.flags = KEY_UP;
@ -82,13 +82,13 @@
key.deviceId = DEVICE_ID_KEYBOARD; key.deviceId = DEVICE_ID_KEYBOARD;
NativeKey(key); NativeKey(key);
} }
} }
- (void)handleKeyUIEvent:(UIEvent *) event { - (void)handleKeyUIEvent:(UIEvent *) event {
if ([event respondsToSelector:@selector(_gsEvent)]) { if ([event respondsToSelector:@selector(_gsEvent)]) {
NSInteger *eventMem; NSInteger *eventMem;
eventMem = (NSInteger *) (__bridge void*)[event performSelector:@selector(_gsEvent)]; eventMem = (NSInteger *) (__bridge void*)[event performSelector:@selector(_gsEvent)];
if (eventMem) { if (eventMem) {
[self decodeKeyEvent:eventMem]; [self decodeKeyEvent:eventMem];
@ -100,7 +100,7 @@
[super sendEvent:event]; [super sendEvent:event];
if ([event respondsToSelector:@selector(_gsEvent)]) { if ([event respondsToSelector:@selector(_gsEvent)]) {
NSInteger *eventMem; NSInteger *eventMem;
eventMem = (NSInteger *) (__bridge void*)[event performSelector:@selector(_gsEvent)]; eventMem = (NSInteger *) (__bridge void*)[event performSelector:@selector(_gsEvent)];
if (eventMem) { if (eventMem) {
[self decodeKeyEvent:eventMem]; [self decodeKeyEvent:eventMem];

View File

@ -269,7 +269,8 @@ SOURCES_CXX += \
$(COMMONDIR)/Data/Text/Parsers.cpp \ $(COMMONDIR)/Data/Text/Parsers.cpp \
$(COMMONDIR)/Data/Text/WrapText.cpp \ $(COMMONDIR)/Data/Text/WrapText.cpp \
$(COMMONDIR)/File/VFS/VFS.cpp \ $(COMMONDIR)/File/VFS/VFS.cpp \
$(COMMONDIR)/File/VFS/AssetReader.cpp \ $(COMMONDIR)/File/VFS/DirectoryReader.cpp \
$(COMMONDIR)/File/VFS/ZipFileReader.cpp \
$(COMMONDIR)/File/AndroidStorage.cpp \ $(COMMONDIR)/File/AndroidStorage.cpp \
$(COMMONDIR)/File/DiskFree.cpp \ $(COMMONDIR)/File/DiskFree.cpp \
$(COMMONDIR)/File/Path.cpp \ $(COMMONDIR)/File/Path.cpp \
@ -818,7 +819,7 @@ SOURCES_CXX += \
$(COMMONDIR)/GPU/D3D9/thin3d_d3d9.cpp \ $(COMMONDIR)/GPU/D3D9/thin3d_d3d9.cpp \
$(COMMONDIR)/GPU/D3D11/D3D11Loader.cpp \ $(COMMONDIR)/GPU/D3D11/D3D11Loader.cpp \
$(COMMONDIR)/GPU/D3D11/thin3d_d3d11.cpp $(COMMONDIR)/GPU/D3D11/thin3d_d3d11.cpp
INCFLAGS += -I$(CORE_DIR)/dx9sdk/Include -I$(CORE_DIR)/dx9sdk/Include/DX11 INCFLAGS += -I$(CORE_DIR)/dx9sdk/Include -I$(CORE_DIR)/dx9sdk/Include/DX11
endif endif

View File

@ -21,7 +21,7 @@
#include "Common/Thread/ThreadUtil.h" #include "Common/Thread/ThreadUtil.h"
#include "Common/Thread/ThreadManager.h" #include "Common/Thread/ThreadManager.h"
#include "Common/File/VFS/VFS.h" #include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/AssetReader.h" #include "Common/File/VFS/DirectoryReader.h"
#include "Common/Data/Text/I18n.h" #include "Common/Data/Text/I18n.h"
#include "Common/StringUtils.h" #include "Common/StringUtils.h"
@ -1284,7 +1284,7 @@ void retro_init(void)
g_Config.bEnableNetworkChat = false; g_Config.bEnableNetworkChat = false;
g_Config.bDiscordPresence = false; g_Config.bDiscordPresence = false;
g_VFS.Register("", new DirectoryAssetReader(retro_base_dir)); g_VFS.Register("", new DirectoryReader(retro_base_dir));
host = new LibretroHost(); host = new LibretroHost();
} }
@ -1561,14 +1561,14 @@ static void retro_input(void)
float y_left = input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / -32767.0f; float y_left = input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / -32767.0f;
float x_right = input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 32767.0f; float x_right = input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 32767.0f;
float y_right = input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / -32767.0f; float y_right = input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / -32767.0f;
__CtrlSetAnalogXY(CTRL_STICK_LEFT, x_left, y_left); __CtrlSetAnalogXY(CTRL_STICK_LEFT, x_left, y_left);
__CtrlSetAnalogXY(CTRL_STICK_RIGHT, x_right, y_right); __CtrlSetAnalogXY(CTRL_STICK_RIGHT, x_right, y_right);
// Analog circle vs square gate compensation // Analog circle vs square gate compensation
// copied from ControlMapper.cpp's ConvertAnalogStick function // copied from ControlMapper.cpp's ConvertAnalogStick function
const bool isCircular = g_Config.bAnalogIsCircular; const bool isCircular = g_Config.bAnalogIsCircular;
float norm = std::max(fabsf(x_left), fabsf(y_left)); float norm = std::max(fabsf(x_left), fabsf(y_left));
if (norm == 0.0f) if (norm == 0.0f)
@ -1585,7 +1585,7 @@ static void retro_input(void)
float mappedNorm = norm; float mappedNorm = norm;
x_left = std::clamp(x_left / norm * mappedNorm, -1.0f, 1.0f); x_left = std::clamp(x_left / norm * mappedNorm, -1.0f, 1.0f);
y_left = std::clamp(y_left / norm * mappedNorm, -1.0f, 1.0f); y_left = std::clamp(y_left / norm * mappedNorm, -1.0f, 1.0f);
__CtrlSetAnalogXY(CTRL_STICK_LEFT, x_left, y_left); __CtrlSetAnalogXY(CTRL_STICK_LEFT, x_left, y_left);
__CtrlSetAnalogXY(CTRL_STICK_RIGHT, x_right, y_right); __CtrlSetAnalogXY(CTRL_STICK_RIGHT, x_right, y_right);
} }