Fix ZipAssetReader file listing. Fixes post shaders on Android

This commit is contained in:
Henrik Rydgård 2021-05-13 11:49:33 +02:00
parent 274be61339
commit 0cd7af44f1
3 changed files with 9 additions and 8 deletions

View File

@ -132,10 +132,9 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vector<File::Fil
info.isDirectory = false;
std::string ext = info.fullName.GetFileExtension();
if (filter) {
if (!ext.empty())
ext = ext.substr(1);
if (filters.find(ext) == filters.end())
if (filters.find(ext) == filters.end()) {
continue;
}
}
listing->push_back(info);
}

View File

@ -24,7 +24,8 @@ void VFSShutdown() {
num_entries = 0;
}
static bool IsLocalPath(const char *path) {
// TODO: Use Path more.
static bool IsLocalAbsolutePath(const char *path) {
bool isUnixLocal = path[0] == '/';
#ifdef _WIN32
bool isWindowsLocal = isalpha(path[0]) && path[1] == ':';
@ -36,7 +37,7 @@ static bool IsLocalPath(const char *path) {
// The returned data should be free'd with delete[].
uint8_t *VFSReadFile(const char *filename, size_t *size) {
if (IsLocalPath(filename)) {
if (IsLocalAbsolutePath(filename)) {
// Local path, not VFS.
// INFO_LOG(IO, "Not a VFS path: %s . Reading local file.", filename);
return File::ReadLocalFile(filename, size);
@ -65,7 +66,7 @@ uint8_t *VFSReadFile(const char *filename, size_t *size) {
}
bool VFSGetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter) {
if (IsLocalPath(path)) {
if (IsLocalAbsolutePath(path)) {
// Local path, not VFS.
// INFO_LOG(IO, "Not a VFS path: %s . Reading local directory.", path);
File::GetFilesInDir(Path(std::string(path)), listing, filter);
@ -92,7 +93,7 @@ bool VFSGetFileListing(const char *path, std::vector<File::FileInfo> *listing, c
}
bool VFSGetFileInfo(const char *path, File::FileInfo *info) {
if (IsLocalPath(path)) {
if (IsLocalAbsolutePath(path)) {
// Local path, not VFS.
// INFO_LOG(IO, "Not a VFS path: %s . Getting local file info.", path);
return File::GetFileInfo(Path(std::string(path)), info);

View File

@ -22,6 +22,7 @@
#include <vector>
#include <algorithm>
#include "Common/Log.h"
#include "Common/Data/Format/IniFile.h"
#include "Common/File/FileUtil.h"
#include "Common/File/DirListing.h"
@ -183,7 +184,7 @@ void LoadPostShaderInfo(const std::vector<Path> &directories) {
// Scans the directories for shader ini files and collects info about all the shaders found.
void ReloadAllPostShaderInfo() {
std::vector<Path> directories;
directories.push_back(Path("shaders")); // Hm, why?
directories.push_back(Path("shaders")); // For VFS
directories.push_back(g_Config.memStickDirectory / "PSP" / "shaders");
LoadPostShaderInfo(directories);
}