Io: Simulate VFAT bug only when simulating FAT32.

And cleanup flag handling a bit.
This commit is contained in:
Unknown W. Brackets 2020-05-21 15:55:25 -07:00
parent 51db9f0f85
commit 67416e5919
10 changed files with 34 additions and 23 deletions

View File

@ -109,7 +109,7 @@ int BlobFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 out
}
int BlobFileSystem::DevType(u32 handle) {
return -1;
return PSP_DEV_TYPE_FILE;
}
bool BlobFileSystem::MkDir(const std::string &dirname) {

View File

@ -44,7 +44,7 @@ public:
bool OwnsHandle(u32 handle) override;
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
int DevType(u32 handle) override;
int Flags() override { return 0; }
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
bool MkDir(const std::string &dirname) override;
bool RmDir(const std::string &dirname) override;

View File

@ -150,7 +150,7 @@ bool FixPathCase(const std::string &basePath, std::string &path, FixPathCaseBeha
#endif
DirectoryFileSystem::DirectoryFileSystem(IHandleAllocator *_hAlloc, std::string _basePath, int _flags) : basePath(_basePath), flags(_flags) {
DirectoryFileSystem::DirectoryFileSystem(IHandleAllocator *_hAlloc, std::string _basePath, FileSystemFlags _flags) : basePath(_basePath), flags(_flags) {
File::CreateFullPath(basePath);
hAlloc = _hAlloc;
}
@ -874,7 +874,9 @@ std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path) {
entry.size = 4096;
else
entry.size = findData.nFileSizeLow | ((u64)findData.nFileSizeHigh<<32);
entry.name = SimulateVFATBug(ConvertWStringToUTF8(findData.cFileName));
entry.name = ConvertWStringToUTF8(findData.cFileName);
if (Flags() & FileSystemFlags::SIMULATE_FAT32)
entry.name = SimulateVFATBug(entry.name);
bool hideFile = false;
if (hideISOFiles && (endsWithNoCase(entry.name, ".cso") || endsWithNoCase(entry.name, ".iso"))) {
@ -921,7 +923,9 @@ std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path) {
else
entry.type = FILETYPE_NORMAL;
entry.access = s.st_mode & 0x1FF;
entry.name = SimulateVFATBug(dirp->d_name);
entry.name = dirp->d_name;
if (Flags() & FileSystemFlags::SIMULATE_FAT32)
entry.name = SimulateVFATBug(entry.name);
entry.size = s.st_size;
bool hideFile = false;

View File

@ -85,7 +85,7 @@ struct DirectoryFileHandle {
class DirectoryFileSystem : public IFileSystem {
public:
DirectoryFileSystem(IHandleAllocator *_hAlloc, std::string _basePath, int _flags = 0);
DirectoryFileSystem(IHandleAllocator *_hAlloc, std::string _basePath, FileSystemFlags _flags = FileSystemFlags::NONE);
~DirectoryFileSystem();
void CloseAll();
@ -109,7 +109,7 @@ public:
int RenameFile(const std::string &from, const std::string &to) override;
bool RemoveFile(const std::string &filename) override;
bool GetHostPath(const std::string &inpath, std::string &outpath) override;
int Flags() override { return flags; }
FileSystemFlags Flags() override { return flags; }
u64 FreeSpace(const std::string &path) override;
private:
@ -123,7 +123,7 @@ private:
EntryMap entries;
std::string basePath;
IHandleAllocator *hAlloc;
int flags;
FileSystemFlags flags;
// In case of Windows: Translate slashes, etc.
std::string GetLocalPath(std::string localpath);
};
@ -154,7 +154,7 @@ public:
int RenameFile(const std::string &from, const std::string &to) override;
bool RemoveFile(const std::string &filename) override;
bool GetHostPath(const std::string &inpath, std::string &outpath) override;
int Flags() override { return 0; }
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
u64 FreeSpace(const std::string &path) override { return 0; }
private:

View File

@ -50,10 +50,18 @@ enum DevType {
PSP_DEV_TYPE_ALIAS = 0x20,
};
enum FileSystemFlags {
FILESYSTEM_SIMULATE_FAT32 = 1,
enum class FileSystemFlags {
NONE = 0,
SIMULATE_FAT32 = 1,
};
inline FileSystemFlags operator |(const FileSystemFlags &lhs, const FileSystemFlags &rhs) {
return FileSystemFlags((int)lhs | (int)rhs);
}
inline bool operator &(const FileSystemFlags &lhs, const FileSystemFlags &rhs) {
return ((int)lhs & (int)rhs) != 0;
}
class IHandleAllocator {
public:
virtual ~IHandleAllocator() {}
@ -126,7 +134,7 @@ public:
virtual bool GetHostPath(const std::string &inpath, std::string &outpath) = 0;
virtual int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) = 0;
virtual int DevType(u32 handle) = 0;
virtual int Flags() = 0;
virtual FileSystemFlags Flags() = 0;
virtual u64 FreeSpace(const std::string &path) = 0;
};
@ -152,7 +160,7 @@ public:
virtual bool GetHostPath(const std::string &inpath, std::string &outpath) override {return false;}
virtual int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override {return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED; }
virtual int DevType(u32 handle) override { return 0; }
virtual int Flags() override { return 0; }
virtual FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
virtual u64 FreeSpace(const std::string &path) override { return 0; }
};

View File

@ -42,7 +42,7 @@ public:
bool OwnsHandle(u32 handle) override;
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
int DevType(u32 handle) override;
int Flags() override { return 0; }
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
u64 FreeSpace(const std::string &path) override { return 0; }
size_t WriteFile(u32 handle, const u8 *pointer, s64 size) override;
@ -137,7 +137,7 @@ public:
int DevType(u32 handle) override {
return isoFileSystem_->DevType(handle);
}
int Flags() override { return isoFileSystem_->Flags(); }
FileSystemFlags Flags() override { return isoFileSystem_->Flags(); }
u64 FreeSpace(const std::string &path) override { return isoFileSystem_->FreeSpace(path); }
size_t WriteFile(u32 handle, const u8 *pointer, s64 size) override {

View File

@ -115,7 +115,7 @@ public:
bool RemoveFile(const std::string &filename) override;
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
int DevType(u32 handle) override;
int Flags() override { return 0; }
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
u64 FreeSpace(const std::string &path) override;
// Convenience helper - returns < 0 on failure.

View File

@ -41,7 +41,7 @@ public:
int DevType(u32 handle) override;
bool GetHostPath(const std::string &inpath, std::string &outpath) override;
std::vector<PSPFileInfo> GetDirListing(std::string path) override;
int Flags() override { return 0; }
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
u64 FreeSpace(const std::string &path) override { return 0; }
// unsupported operations

View File

@ -621,7 +621,7 @@ void __IoInit() {
asyncNotifyEvent = CoreTiming::RegisterEvent("IoAsyncNotify", __IoAsyncNotify);
syncNotifyEvent = CoreTiming::RegisterEvent("IoSyncNotify", __IoSyncNotify);
memstickSystem = new DirectoryFileSystem(&pspFileSystem, g_Config.memStickDirectory, FILESYSTEM_SIMULATE_FAT32);
memstickSystem = new DirectoryFileSystem(&pspFileSystem, g_Config.memStickDirectory, FileSystemFlags::SIMULATE_FAT32);
#if defined(USING_WIN_UI) || defined(APPLE)
flash0System = new DirectoryFileSystem(&pspFileSystem, g_Config.flash0Directory);
#else
@ -637,7 +637,7 @@ void __IoInit() {
const std::string gameId = g_paramSFO.GetValueString("DISC_ID");
const std::string exdataPath = g_Config.memStickDirectory + "exdata/" + gameId + "/";
if (File::Exists(exdataPath)) {
exdataSystem = new DirectoryFileSystem(&pspFileSystem, exdataPath, FILESYSTEM_SIMULATE_FAT32);
exdataSystem = new DirectoryFileSystem(&pspFileSystem, exdataPath, FileSystemFlags::SIMULATE_FAT32);
pspFileSystem.Mount("exdata0:", exdataSystem);
INFO_LOG(SCEIO, "Mounted exdata/%s/ under memstick for exdata0:/", gameId.c_str());
} else {
@ -1423,8 +1423,7 @@ static u32 sceIoLseek32Async(int id, int offset, int whence) {
return 0;
}
static FileNode *__IoOpen(int &error, const char* filename, int flags, int mode) {
//memory stick filename
static FileNode *__IoOpen(int &error, const char *filename, int flags, int mode) {
int access = FILEACCESS_NONE;
if (flags & PSP_O_RDONLY)
access |= FILEACCESS_READ;
@ -2290,7 +2289,7 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
bool isFAT = false;
IFileSystem *sys = pspFileSystem.GetSystemFromFilename(dir->name);
if (sys && (sys->Flags() & FILESYSTEM_SIMULATE_FAT32))
if (sys && (sys->Flags() & FileSystemFlags::SIMULATE_FAT32))
isFAT = true;
else
isFAT = false;

View File

@ -386,7 +386,7 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
pspFileSystem.SetStartingDirectory(ms_path);
}
DirectoryFileSystem *fs = new DirectoryFileSystem(&pspFileSystem, path);
DirectoryFileSystem *fs = new DirectoryFileSystem(&pspFileSystem, path, FileSystemFlags::SIMULATE_FAT32);
pspFileSystem.Mount("umd0:", fs);
std::string finalName = ms_path + file + extension;