diff --git a/Common/Data/Format/JSONReader.cpp b/Common/Data/Format/JSONReader.cpp index 331c54be64..86c18df54c 100644 --- a/Common/Data/Format/JSONReader.cpp +++ b/Common/Data/Format/JSONReader.cpp @@ -1,4 +1,5 @@ #include "Common/File/VFS/VFS.h" +#include "Common/File/Path.h" #include "Common/File/FileUtil.h" #include "Common/Data/Format/JSONReader.h" @@ -11,7 +12,7 @@ JsonReader::JsonReader(const std::string &filename) { parse(); } else { // Okay, try to read on the local file system - buffer_ = (char *)File::ReadLocalFile(filename.c_str(), &buf_size); + buffer_ = (char *)File::ReadLocalFile(Path(filename), &buf_size); if (buffer_) { parse(); } else { diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 8917763b1e..7a35ded386 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -987,10 +987,8 @@ bool ReadFileToString(bool text_file, const Path &filename, std::string &str) { return success; } -// This is an odd one, mainly used for asset reading, so doesn't really -// need to support Path. -uint8_t *ReadLocalFile(const char *filename, size_t * size) { - FILE *file = File::OpenCFile(Path(filename), "rb"); +uint8_t *ReadLocalFile(const Path &filename, size_t *size) { + FILE *file = File::OpenCFile(filename, "rb"); if (!file) { *size = 0; return nullptr; diff --git a/Common/File/FileUtil.h b/Common/File/FileUtil.h index ab0782fb22..ed0581b66c 100644 --- a/Common/File/FileUtil.h +++ b/Common/File/FileUtil.h @@ -201,6 +201,6 @@ bool WriteDataToFile(bool text_file, const void* data, const unsigned int size, bool ReadFileToString(bool text_file, const Path &filename, std::string &str); // Return value must be delete[]-d. -uint8_t *ReadLocalFile(const char *filename, size_t *size); +uint8_t *ReadLocalFile(const Path &filename, size_t *size); } // namespace diff --git a/Common/File/VFS/AssetReader.cpp b/Common/File/VFS/AssetReader.cpp index 77bd76df22..6bc96773f7 100644 --- a/Common/File/VFS/AssetReader.cpp +++ b/Common/File/VFS/AssetReader.cpp @@ -172,7 +172,7 @@ DirectoryAssetReader::DirectoryAssetReader(const 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.c_str(), size); + return File::ReadLocalFile(new_path, size); } bool DirectoryAssetReader::GetFileListing(const char *path, std::vector *listing, const char *filter = nullptr) { diff --git a/Common/File/VFS/VFS.cpp b/Common/File/VFS/VFS.cpp index ff6dd37430..cf347dcf44 100644 --- a/Common/File/VFS/VFS.cpp +++ b/Common/File/VFS/VFS.cpp @@ -1,6 +1,7 @@ #include "Common/Log.h" #include "Common/File/VFS/VFS.h" #include "Common/File/VFS/AssetReader.h" +#include "Common/File/AndroidStorage.h" struct VFSEntry { const char *prefix; @@ -32,7 +33,8 @@ static bool IsLocalAbsolutePath(const char *path) { #else bool isWindowsLocal = false; #endif - return isUnixLocal || isWindowsLocal; + bool isContentURI = Android_IsContentUri(path); + return isUnixLocal || isWindowsLocal || isContentURI; } // The returned data should be free'd with delete[]. @@ -40,7 +42,7 @@ uint8_t *VFSReadFile(const char *filename, size_t *size) { if (IsLocalAbsolutePath(filename)) { // Local path, not VFS. // INFO_LOG(IO, "Not a VFS path: %s . Reading local file.", filename); - return File::ReadLocalFile(filename, size); + return File::ReadLocalFile(Path(filename), size); } int fn_len = (int)strlen(filename); diff --git a/Common/GPU/OpenGL/GLSLProgram.cpp b/Common/GPU/OpenGL/GLSLProgram.cpp index 0bca65c6f3..0782593c35 100644 --- a/Common/GPU/OpenGL/GLSLProgram.cpp +++ b/Common/GPU/OpenGL/GLSLProgram.cpp @@ -104,7 +104,7 @@ bool glsl_recompile(GLSLProgram *program, std::string *error_message) { program->vshader_mtime = vs.st_mtime; if (!program->vshader_source) { size_t sz; - vsh_src.reset((char *)File::ReadLocalFile(program->vshader_filename, &sz)); + vsh_src.reset((char *)File::ReadLocalFile(Path(program->vshader_filename), &sz)); } } else { program->vshader_mtime = 0; @@ -114,7 +114,7 @@ bool glsl_recompile(GLSLProgram *program, std::string *error_message) { program->fshader_mtime = fs.st_mtime; if (!program->fshader_source) { size_t sz; - fsh_src.reset((char *)File::ReadLocalFile(program->fshader_filename, &sz)); + fsh_src.reset((char *)File::ReadLocalFile(Path(program->fshader_filename), &sz)); } } else { program->fshader_mtime = 0;