mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-15 02:29:51 +01:00
Merge remote-tracking branch 'remotes/Unknown/io-minor' into TemporaryHackishBranch
This commit is contained in:
commit
55ebcf9ff2
18 files changed
+85
-91
No files matched your search
@@ -129,18 +129,20 @@ void PSPGamedataInstallDialog::OpenNextFile() {
|
||||
std::string outputFileName = GetGameDataInstallFileName(&request, inFileNames[readFiles]);
|
||||
|
||||
currentInputFile = pspFileSystem.OpenFile(inputFileName, FILEACCESS_READ);
|
||||
if (!currentInputFile) {
|
||||
if (currentInputFile < 0) {
|
||||
// TODO: Generate an error code?
|
||||
ERROR_LOG_REPORT(SCEUTILITY, "Unable to read from install file: %s", inFileNames[readFiles].c_str());
|
||||
++readFiles;
|
||||
currentInputFile = 0;
|
||||
return;
|
||||
}
|
||||
currentOutputFile = pspFileSystem.OpenFile(outputFileName, (FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE | FILEACCESS_TRUNCATE));
|
||||
if (!currentOutputFile) {
|
||||
if (currentOutputFile < 0) {
|
||||
// TODO: Generate an error code?
|
||||
ERROR_LOG(SCEUTILITY, "Unable to write to install file: %s", inFileNames[readFiles].c_str());
|
||||
pspFileSystem.CloseFile(currentInputFile);
|
||||
currentInputFile = 0;
|
||||
currentOutputFile = 0;
|
||||
++readFiles;
|
||||
return;
|
||||
}
|
||||
@@ -172,10 +174,12 @@ void PSPGamedataInstallDialog::CopyCurrentFileData() {
|
||||
}
|
||||
|
||||
void PSPGamedataInstallDialog::CloseCurrentFile() {
|
||||
pspFileSystem.CloseFile(currentOutputFile);
|
||||
if (currentOutputFile >= 0)
|
||||
pspFileSystem.CloseFile(currentOutputFile);
|
||||
currentOutputFile = 0;
|
||||
|
||||
pspFileSystem.CloseFile(currentInputFile);
|
||||
if (currentInputFile >= 0)
|
||||
pspFileSystem.CloseFile(currentInputFile);
|
||||
currentInputFile = 0;
|
||||
|
||||
++readFiles;
|
||||
@@ -208,7 +212,7 @@ void PSPGamedataInstallDialog::WriteSfoFile() {
|
||||
sfoFile.WriteSFO(&sfoData,&sfoSize);
|
||||
|
||||
u32 handle = pspFileSystem.OpenFile(sfopath, (FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE | FILEACCESS_TRUNCATE));
|
||||
if (handle != 0) {
|
||||
if (handle >= 0) {
|
||||
pspFileSystem.WriteFile(handle, sfoData, sfoSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace
|
||||
bool ReadPSPFile(std::string filename, u8 **data, s64 dataSize, s64 *readSize)
|
||||
{
|
||||
u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ);
|
||||
if (handle == 0)
|
||||
if (handle < 0)
|
||||
return false;
|
||||
|
||||
if(dataSize == -1)
|
||||
@@ -82,7 +82,7 @@ namespace
|
||||
bool WritePSPFile(std::string filename, u8 *data, SceSize dataSize)
|
||||
{
|
||||
u32 handle = pspFileSystem.OpenFile(filename, (FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE | FILEACCESS_TRUNCATE));
|
||||
if (handle == 0)
|
||||
if (handle < 0)
|
||||
return false;
|
||||
|
||||
size_t result = pspFileSystem.WriteFile(handle, data, dataSize);
|
||||
@@ -209,7 +209,7 @@ void SavedataParam::Init()
|
||||
// Create a nomedia file to hide save icons form Android image viewer
|
||||
#ifdef __ANDROID__
|
||||
int handle = pspFileSystem.OpenFile(savePath + ".nomedia", (FileAccess)(FILEACCESS_CREATE | FILEACCESS_WRITE), 0);
|
||||
if (handle) {
|
||||
if (handle >= 0) {
|
||||
pspFileSystem.CloseFile(handle);
|
||||
} else {
|
||||
ELOG("Failed to create .nomedia file");
|
||||
|
||||
@@ -36,7 +36,7 @@ std::vector<PSPFileInfo> BlobFileSystem::GetDirListing(std::string path) {
|
||||
return listing;
|
||||
}
|
||||
|
||||
u32 BlobFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
int BlobFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
u32 newHandle = alloc_->GetNewHandle();
|
||||
entries_[newHandle] = 0;
|
||||
return newHandle;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017- PPSSPP Project.
|
||||
// Copyright (c) 2017- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
void DoState(PointerWrap &p) override;
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override;
|
||||
u32 OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override;
|
||||
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override;
|
||||
void CloseFile(u32 handle) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) override;
|
||||
|
||||
@@ -607,7 +607,7 @@ bool DirectoryFileSystem::RemoveFile(const std::string &filename) {
|
||||
return ReplayApplyDisk(ReplayAction::FILE_REMOVE, retValue, CoreTiming::GetGlobalTimeUs()) != 0;
|
||||
}
|
||||
|
||||
u32 DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
int DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
OpenFileEntry entry;
|
||||
u32 err = 0;
|
||||
bool success = entry.hFile.Open(basePath, filename, access, err);
|
||||
@@ -1044,10 +1044,10 @@ bool VFSFileSystem::RemoveFile(const std::string &filename) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 VFSFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
int VFSFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
if (access != FILEACCESS_READ) {
|
||||
ERROR_LOG(FILESYS, "VFSFileSystem only supports plain reading");
|
||||
return 0;
|
||||
return SCE_KERNEL_ERROR_ERRNO_INVALID_FLAG;
|
||||
}
|
||||
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
@@ -1058,7 +1058,7 @@ u32 VFSFileSystem::OpenFile(std::string filename, FileAccess access, const char
|
||||
u8 *data = VFSReadFile(fullNameC, &size);
|
||||
if (!data) {
|
||||
ERROR_LOG(FILESYS, "VFSFileSystem failed to open %s", filename.c_str());
|
||||
return 0;
|
||||
return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
OpenFileEntry entry;
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
void DoState(PointerWrap &p) override;
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override;
|
||||
u32 OpenFile(std::string filename, FileAccess access, const char *devicename=NULL) override;
|
||||
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override;
|
||||
void CloseFile(u32 handle) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) override;
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
|
||||
void DoState(PointerWrap &p) override;
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override;
|
||||
u32 OpenFile(std::string filename, FileAccess access, const char *devicename=NULL) override;
|
||||
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override;
|
||||
void CloseFile(u32 handle) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) override;
|
||||
|
||||
@@ -67,7 +67,8 @@ public:
|
||||
virtual u32 GetNewHandle() override {
|
||||
u32 res = handle_++;
|
||||
if (handle_ < 0) {
|
||||
handle_ = 0;
|
||||
// Some code assumes it'll never become 0.
|
||||
handle_ = 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -109,7 +110,7 @@ public:
|
||||
|
||||
virtual void DoState(PointerWrap &p) = 0;
|
||||
virtual std::vector<PSPFileInfo> GetDirListing(std::string path) = 0;
|
||||
virtual u32 OpenFile(std::string filename, FileAccess access, const char *devicename=nullptr) = 0;
|
||||
virtual int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) = 0;
|
||||
virtual void CloseFile(u32 handle) = 0;
|
||||
virtual size_t ReadFile(u32 handle, u8 *pointer, s64 size) = 0;
|
||||
virtual size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) = 0;
|
||||
@@ -135,7 +136,7 @@ class EmptyFileSystem : public IFileSystem
|
||||
public:
|
||||
virtual void DoState(PointerWrap &p) override {}
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override {std::vector<PSPFileInfo> vec; return vec;}
|
||||
u32 OpenFile(std::string filename, FileAccess access, const char *devicename=nullptr) override {return 0;}
|
||||
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override {return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;}
|
||||
void CloseFile(u32 handle) override {}
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size) override {return 0;}
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) override {return 0;}
|
||||
|
||||
@@ -330,18 +330,23 @@ ISOFileSystem::TreeEntry *ISOFileSystem::GetFromPath(const std::string &path, bo
|
||||
}
|
||||
}
|
||||
|
||||
u32 ISOFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
int ISOFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
|
||||
OpenFileEntry entry;
|
||||
entry.isRawSector = false;
|
||||
entry.isBlockSectorMode = false;
|
||||
|
||||
if (access & FILEACCESS_WRITE) {
|
||||
ERROR_LOG(FILESYS, "Can't open file %s with write access on an ISO partition", filename.c_str());
|
||||
return SCE_KERNEL_ERROR_ERRNO_INVALID_FLAG;
|
||||
}
|
||||
|
||||
if (filename.compare(0, 8, "/sce_lbn") == 0) {
|
||||
// Raw sector read.
|
||||
u32 sectorStart = 0xFFFFFFFF, readSize = 0xFFFFFFFF;
|
||||
parseLBN(filename, §orStart, &readSize);
|
||||
if (sectorStart > blockDevice->GetNumBlocks()) {
|
||||
WARN_LOG(FILESYS, "Unable to open raw sector, out of range: %s, sector %08x, max %08x", filename.c_str(), sectorStart, blockDevice->GetNumBlocks());
|
||||
return 0;
|
||||
return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
}
|
||||
else if (sectorStart == blockDevice->GetNumBlocks())
|
||||
{
|
||||
@@ -364,15 +369,10 @@ u32 ISOFileSystem::OpenFile(std::string filename, FileAccess access, const char
|
||||
return newHandle;
|
||||
}
|
||||
|
||||
if (access & FILEACCESS_WRITE) {
|
||||
ERROR_LOG(FILESYS, "Can't open file %s with write access on an ISO partition", filename.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// May return entireISO for "umd0:"
|
||||
entry.file = GetFromPath(filename);
|
||||
if (!entry.file){
|
||||
return 0;
|
||||
return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (entry.file == &entireISO)
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
void DoState(PointerWrap &p) override;
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override;
|
||||
u32 OpenFile(std::string filename, FileAccess access, const char *devicename = NULL) override;
|
||||
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override;
|
||||
void CloseFile(u32 handle) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) override;
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
}
|
||||
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override { return std::vector<PSPFileInfo>(); }
|
||||
u32 OpenFile(std::string filename, FileAccess access, const char *devicename = NULL) override {
|
||||
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override {
|
||||
return isoFileSystem_->OpenFile("", access, devicename);
|
||||
}
|
||||
void CloseFile(u32 handle) override {
|
||||
|
||||
@@ -176,8 +176,9 @@ IFileSystem *MetaFileSystem::GetHandleOwner(u32 handle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, MountPoint **system)
|
||||
int MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, MountPoint **system)
|
||||
{
|
||||
int error = -1;
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
std::string realpath;
|
||||
|
||||
@@ -216,7 +217,7 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
|
||||
//Attempt to emulate SCE_KERNEL_ERROR_NOCWD / 8002032C: may break things requiring fixes elsewhere
|
||||
if (inpath.find(':') == std::string::npos /* means path is relative */)
|
||||
{
|
||||
lastOpenError = SCE_KERNEL_ERROR_NOCWD;
|
||||
error = SCE_KERNEL_ERROR_NOCWD;
|
||||
WARN_LOG(FILESYS, "Path is relative, but current directory not set for thread %i. returning 8002032C(SCE_KERNEL_ERROR_NOCWD) instead.", currentThread);
|
||||
}
|
||||
}
|
||||
@@ -242,13 +243,13 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
|
||||
|
||||
VERBOSE_LOG(FILESYS, "MapFilePath: mapped \"%s\" to prefix: \"%s\", path: \"%s\"", inpath.c_str(), fileSystems[i].prefix.c_str(), outpath.c_str());
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG(FILESYS, "MapFilePath: failed mapping \"%s\", returning false", inpath.c_str());
|
||||
return false;
|
||||
return error;
|
||||
}
|
||||
|
||||
std::string MetaFileSystem::NormalizePrefix(std::string prefix) const {
|
||||
@@ -332,34 +333,16 @@ void MetaFileSystem::Shutdown()
|
||||
startingDirectory = "";
|
||||
}
|
||||
|
||||
u32 MetaFileSystem::OpenWithError(int &error, std::string filename, FileAccess access, const char *devicename)
|
||||
int MetaFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
u32 h = OpenFile(filename, access, devicename);
|
||||
error = lastOpenError;
|
||||
return h;
|
||||
}
|
||||
|
||||
u32 MetaFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
lastOpenError = 0;
|
||||
std::string of;
|
||||
MountPoint *mount;
|
||||
if (MapFilePath(filename, of, &mount))
|
||||
{
|
||||
s32 res = mount->system->OpenFile(of, access, mount->prefix.c_str());
|
||||
if (res < 0)
|
||||
{
|
||||
lastOpenError = res;
|
||||
return 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
int error = MapFilePath(filename, of, &mount);
|
||||
if (error == 0)
|
||||
return mount->system->OpenFile(of, access, mount->prefix.c_str());
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return error == -1 ? SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND : error;
|
||||
}
|
||||
|
||||
PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename)
|
||||
@@ -367,7 +350,7 @@ PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename)
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(filename, of, &system))
|
||||
if (MapFilePath(filename, of, &system) == 0)
|
||||
{
|
||||
return system->GetFileInfo(of);
|
||||
}
|
||||
@@ -383,7 +366,7 @@ bool MetaFileSystem::GetHostPath(const std::string &inpath, std::string &outpath
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(inpath, of, &system)) {
|
||||
if (MapFilePath(inpath, of, &system) == 0) {
|
||||
return system->GetHostPath(of, outpath);
|
||||
} else {
|
||||
return false;
|
||||
@@ -395,7 +378,7 @@ std::vector<PSPFileInfo> MetaFileSystem::GetDirListing(std::string path)
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(path, of, &system))
|
||||
if (MapFilePath(path, of, &system) == 0)
|
||||
{
|
||||
return system->GetDirListing(of);
|
||||
}
|
||||
@@ -423,7 +406,7 @@ int MetaFileSystem::ChDir(const std::string &dir)
|
||||
|
||||
std::string of;
|
||||
MountPoint *mountPoint;
|
||||
if (MapFilePath(dir, of, &mountPoint))
|
||||
if (MapFilePath(dir, of, &mountPoint) == 0)
|
||||
{
|
||||
currentDir[curThread] = mountPoint->prefix + of;
|
||||
return 0;
|
||||
@@ -452,7 +435,7 @@ bool MetaFileSystem::MkDir(const std::string &dirname)
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(dirname, of, &system))
|
||||
if (MapFilePath(dirname, of, &system) == 0)
|
||||
{
|
||||
return system->MkDir(of);
|
||||
}
|
||||
@@ -467,7 +450,7 @@ bool MetaFileSystem::RmDir(const std::string &dirname)
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(dirname, of, &system))
|
||||
if (MapFilePath(dirname, of, &system) == 0)
|
||||
{
|
||||
return system->RmDir(of);
|
||||
}
|
||||
@@ -484,7 +467,7 @@ int MetaFileSystem::RenameFile(const std::string &from, const std::string &to)
|
||||
std::string rf;
|
||||
IFileSystem *osystem;
|
||||
IFileSystem *rsystem = NULL;
|
||||
if (MapFilePath(from, of, &osystem))
|
||||
if (MapFilePath(from, of, &osystem) == 0)
|
||||
{
|
||||
// If it's a relative path, it seems to always use from's filesystem.
|
||||
if (to.find(":/") != to.npos)
|
||||
@@ -514,7 +497,7 @@ bool MetaFileSystem::RemoveFile(const std::string &filename)
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(filename, of, &system))
|
||||
if (MapFilePath(filename, of, &system) == 0)
|
||||
{
|
||||
return system->RemoveFile(of);
|
||||
}
|
||||
@@ -601,10 +584,9 @@ size_t MetaFileSystem::SeekFile(u32 handle, s32 position, FileMove type)
|
||||
}
|
||||
|
||||
int MetaFileSystem::ReadEntireFile(const std::string &filename, std::vector<u8> &data) {
|
||||
int error = 0;
|
||||
u32 handle = OpenWithError(error, filename, FILEACCESS_READ);
|
||||
if (handle == 0)
|
||||
return error;
|
||||
int handle = OpenFile(filename, FILEACCESS_READ);
|
||||
if (handle < 0)
|
||||
return handle;
|
||||
|
||||
size_t dataSize = (size_t)GetFileInfo(filename).size;
|
||||
data.resize(dataSize);
|
||||
@@ -622,7 +604,7 @@ u64 MetaFileSystem::FreeSpace(const std::string &path)
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(path, of, &system))
|
||||
if (MapFilePath(path, of, &system) == 0)
|
||||
return system->FreeSpace(of);
|
||||
else
|
||||
return 0;
|
||||
|
||||
@@ -41,12 +41,13 @@ private:
|
||||
currentDir_t currentDir;
|
||||
|
||||
std::string startingDirectory;
|
||||
int lastOpenError;
|
||||
std::recursive_mutex lock; // must be recursive
|
||||
|
||||
public:
|
||||
MetaFileSystem() {
|
||||
current = 6; // what?
|
||||
// This used to be 6, probably an attempt to replicate PSP handles.
|
||||
// However, that's an artifact of using psplink anyway...
|
||||
current = 1;
|
||||
}
|
||||
|
||||
void Mount(std::string prefix, IFileSystem *system);
|
||||
@@ -63,7 +64,8 @@ public:
|
||||
u32 GetNewHandle() override {
|
||||
u32 res = current++;
|
||||
if (current < 0) {
|
||||
current = 0;
|
||||
// Some code assumes it'll never become 0.
|
||||
current = 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -72,16 +74,17 @@ public:
|
||||
void DoState(PointerWrap &p) override;
|
||||
|
||||
IFileSystem *GetHandleOwner(u32 handle);
|
||||
bool MapFilePath(const std::string &inpath, std::string &outpath, MountPoint **system);
|
||||
int MapFilePath(const std::string &inpath, std::string &outpath, MountPoint **system);
|
||||
|
||||
inline bool MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system) {
|
||||
inline int MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system) {
|
||||
MountPoint *mountPoint;
|
||||
if (MapFilePath(_inpath, outpath, &mountPoint)) {
|
||||
int error = MapFilePath(_inpath, outpath, &mountPoint);
|
||||
if (error == 0) {
|
||||
*system = mountPoint->system;
|
||||
return true;
|
||||
return error;
|
||||
}
|
||||
|
||||
return false;
|
||||
return error;
|
||||
}
|
||||
|
||||
std::string NormalizePrefix(std::string prefix) const;
|
||||
@@ -90,8 +93,7 @@ public:
|
||||
bool GetHostPath(const std::string &inpath, std::string &outpath) override;
|
||||
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override;
|
||||
u32 OpenFile(std::string filename, FileAccess access, const char *devicename = NULL) override;
|
||||
u32 OpenWithError(int &error, std::string filename, FileAccess access, const char *devicename = NULL);
|
||||
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override;
|
||||
void CloseFile(u32 handle) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) override;
|
||||
|
||||
@@ -321,7 +321,7 @@ int VirtualDiscFileSystem::getFileListIndex(u32 accessBlock, u32 accessSize, boo
|
||||
return -1;
|
||||
}
|
||||
|
||||
u32 VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename)
|
||||
int VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename)
|
||||
{
|
||||
OpenFileEntry entry;
|
||||
entry.curOffset = 0;
|
||||
@@ -396,7 +396,7 @@ u32 VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, con
|
||||
ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED, access = %i", (int)access);
|
||||
#endif
|
||||
//wwwwaaaaahh!!
|
||||
return 0;
|
||||
return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
} else {
|
||||
u32 newHandle = hAlloc->GetNewHandle();
|
||||
entries[newHandle] = entry;
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
~VirtualDiscFileSystem();
|
||||
|
||||
void DoState(PointerWrap &p) override;
|
||||
u32 OpenFile(std::string filename, FileAccess access, const char *devicename=NULL) override;
|
||||
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override;
|
||||
size_t SeekFile(u32 handle, s32 position, FileMove type) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size) override;
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) override;
|
||||
|
||||
+5
-3
@@ -1434,10 +1434,12 @@ static FileNode *__IoOpen(int &error, const char* filename, int flags, int mode)
|
||||
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
|
||||
|
||||
u32 h = pspFileSystem.OpenWithError(error, filename, (FileAccess) access);
|
||||
if (h == 0) {
|
||||
return NULL;
|
||||
int h = pspFileSystem.OpenFile(filename, (FileAccess)access);
|
||||
if (h < 0) {
|
||||
error = h;
|
||||
return nullptr;
|
||||
}
|
||||
error = 0;
|
||||
|
||||
FileNode *f = new FileNode();
|
||||
SceUID id = kernelObjects.Create(f);
|
||||
|
||||
@@ -1163,7 +1163,7 @@ static int scePsmfPlayerBreak(u32 psmfPlayer)
|
||||
}
|
||||
|
||||
static int _PsmfPlayerFillRingbuffer(PsmfPlayer *psmfplayer) {
|
||||
if (!psmfplayer->filehandle)
|
||||
if (psmfplayer->filehandle <= 0)
|
||||
return -1;
|
||||
u8* buf = psmfplayer->tempbuf;
|
||||
int tempbufSize = (int)sizeof(psmfplayer->tempbuf);
|
||||
@@ -1207,7 +1207,7 @@ static int _PsmfPlayerSetPsmfOffset(u32 psmfPlayer, const char *filename, int of
|
||||
int delayUs = 1100;
|
||||
|
||||
psmfplayer->filehandle = pspFileSystem.OpenFile(filename, (FileAccess) FILEACCESS_READ);
|
||||
if (!psmfplayer->filehandle) {
|
||||
if (psmfplayer->filehandle < 0) {
|
||||
return hleDelayResult(SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT, "psmfplayer set", delayUs);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
|
||||
|
||||
bool hasEncrypted = false;
|
||||
u32 fd;
|
||||
if ((fd = pspFileSystem.OpenFile(bootpath, FILEACCESS_READ)) != 0)
|
||||
if ((fd = pspFileSystem.OpenFile(bootpath, FILEACCESS_READ)) >= 0)
|
||||
{
|
||||
u8 head[4];
|
||||
pspFileSystem.ReadFile(fd, head, 4);
|
||||
|
||||
@@ -413,10 +413,13 @@ std::string GameManager::GetISOGameID(FileLoader *loader) const {
|
||||
ISOFileSystem umd(&handles, bd);
|
||||
|
||||
PSPFileInfo info = umd.GetFileInfo("/PSP_GAME/PARAM.SFO");
|
||||
int handle = 0;
|
||||
int handle = -1;
|
||||
if (info.exists) {
|
||||
handle = umd.OpenFile("/PSP_GAME/PARAM.SFO", FILEACCESS_READ);
|
||||
}
|
||||
if (handle < 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string sfoData;
|
||||
sfoData.resize(info.size);
|
||||
|
||||
@@ -301,7 +301,7 @@ static bool ReadFileToString(IFileSystem *fs, const char *filename, std::string
|
||||
}
|
||||
|
||||
int handle = fs->OpenFile(filename, FILEACCESS_READ);
|
||||
if (!handle) {
|
||||
if (handle < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user