mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
@@ -72,10 +72,10 @@ LocalFileLoader::LocalFileLoader(const Path &filename)
|
||||
return;
|
||||
}
|
||||
fd_ = fd;
|
||||
isOpenedByFd_ = true;
|
||||
DetectSizeFd();
|
||||
return;
|
||||
}
|
||||
// else, fall through to normal file loading (legacy build, old Android etc).
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LIBRETRO_VFS)
|
||||
@@ -153,20 +153,13 @@ bool LocalFileLoader::Exists() {
|
||||
// If we opened it for reading, it must exist. Done.
|
||||
#if defined(HAVE_LIBRETRO_VFS)
|
||||
return file_ != nullptr;
|
||||
#elif PPSSPP_PLATFORM(IOS)
|
||||
return fd_ != -1;
|
||||
#elif !defined(_WIN32)
|
||||
if (isOpenedByFd_) {
|
||||
// As an optimization, if we already tried and failed, quickly return.
|
||||
// This is used because Android Content URIs are so slow.
|
||||
return fd_ != -1;
|
||||
}
|
||||
if (fd_ != -1)
|
||||
return true;
|
||||
return fd_ != -1;
|
||||
#else
|
||||
if (handle_ != INVALID_HANDLE_VALUE)
|
||||
return true;
|
||||
return handle_ != INVALID_HANDLE_VALUE;
|
||||
#endif
|
||||
|
||||
return File::Exists(filename_);
|
||||
}
|
||||
|
||||
bool LocalFileLoader::IsDirectory() {
|
||||
@@ -182,8 +175,9 @@ s64 LocalFileLoader::FileSize() {
|
||||
}
|
||||
|
||||
size_t LocalFileLoader::ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags) {
|
||||
if (bytes == 0)
|
||||
if (bytes == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (filesize_ == 0) {
|
||||
ERROR_LOG(Log::FileSystem, "ReadAt from 0-sized file: %s", filename_.c_str());
|
||||
|
||||
@@ -53,5 +53,4 @@ private:
|
||||
u64 filesize_ = 0;
|
||||
Path filename_;
|
||||
std::mutex readLock_;
|
||||
bool isOpenedByFd_ = false;
|
||||
};
|
||||
|
||||
@@ -222,7 +222,7 @@ static bool FindUDFLayerFileEntrySectors(FileLoader *fileLoader, u32 rootSector,
|
||||
BlockDevice *ConstructBlockDevice(FileLoader *fileLoader, std::string *errorString) {
|
||||
if (!fileLoader->Exists()) {
|
||||
// Shouldn't get here really.
|
||||
*errorString = "File doesn't exist";
|
||||
*errorString = "File not readable or doesn't exist";
|
||||
return nullptr;
|
||||
}
|
||||
if (fileLoader->IsDirectory()) {
|
||||
@@ -230,12 +230,16 @@ BlockDevice *ConstructBlockDevice(FileLoader *fileLoader, std::string *errorStri
|
||||
*errorString += fileLoader->GetPath().ToString();
|
||||
return nullptr;
|
||||
}
|
||||
if (fileLoader->FileSize() < 8) {
|
||||
*errorString = "File is too small to read the header.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char buffer[8]{};
|
||||
size_t size = fileLoader->ReadAt(0, 1, 8, buffer);
|
||||
if (size != 8) {
|
||||
// Bad or empty file
|
||||
*errorString = "File is empty";
|
||||
*errorString = "Failed to read 8-byte header";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public:
|
||||
virtual bool IsRemote() {
|
||||
return false;
|
||||
}
|
||||
virtual bool Exists() = 0;
|
||||
virtual bool Exists() = 0; // This is permitted to essentially be "IsReadable" and not actually report existence (let's say the permissions are wrong, for example...)
|
||||
virtual bool ExistsFast() {
|
||||
return Exists();
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ R"( mat4 u_proj;
|
||||
mat3x4 u_world;
|
||||
mat3x4 u_texmtx;
|
||||
vec4 u_xywh;
|
||||
vec3 u_vpScale; float u_NaN; // w = offsetX
|
||||
vec4 u_vpOffset; // w = offsetY
|
||||
vec3 u_vpScale; float u_NaN;
|
||||
vec4 u_vpOffset;
|
||||
vec2 u_rasterOffset; vec2 u_minZmaxZ;
|
||||
vec4 u_uvscaleoffset;
|
||||
vec4 u_matambientalpha;
|
||||
|
||||
Reference in New Issue
Block a user