Skip to content

Commit

Permalink
Fix ZipAssetReader file listing. Fixes post shaders on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed May 13, 2021
1 parent 274be61 commit 0cd7af4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 2 additions & 3 deletions Common/File/VFS/AssetReader.cpp
Expand Up @@ -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);
}
Expand Down
9 changes: 5 additions & 4 deletions Common/File/VFS/VFS.cpp
Expand Up @@ -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] == ':';
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion GPU/Common/PostShader.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 0cd7af4

Please sign in to comment.