mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Io: Track whether the game is on a UMD or storage.
This commit is contained in:
parent
67416e5919
commit
c829ccb87d
10 changed files with 26 additions and 15 deletions
|
@ -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;
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::FLASH; }
|
||||
|
||||
bool MkDir(const std::string &dirname) override;
|
||||
bool RmDir(const std::string &dirname) override;
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
}
|
||||
int GetBlockSize() const { return 2048;} // forced, it cannot be changed by subclasses
|
||||
virtual u32 GetNumBlocks() = 0;
|
||||
virtual bool IsDisc() = 0;
|
||||
|
||||
u32 CalculateCRC();
|
||||
void NotifyReadError();
|
||||
|
@ -60,6 +61,7 @@ public:
|
|||
bool ReadBlock(int blockNumber, u8 *outPtr, bool uncached = false) override;
|
||||
bool ReadBlocks(u32 minBlock, int count, u8 *outPtr) override;
|
||||
u32 GetNumBlocks() override { return numBlocks; }
|
||||
bool IsDisc() override { return true; }
|
||||
|
||||
private:
|
||||
FileLoader *fileLoader_;
|
||||
|
@ -83,6 +85,7 @@ public:
|
|||
bool ReadBlock(int blockNumber, u8 *outPtr, bool uncached = false) override;
|
||||
bool ReadBlocks(u32 minBlock, int count, u8 *outPtr) override;
|
||||
u32 GetNumBlocks() override {return (u32)(filesize_ / GetBlockSize());}
|
||||
bool IsDisc() override { return true; }
|
||||
|
||||
private:
|
||||
FileLoader *fileLoader_;
|
||||
|
@ -107,6 +110,7 @@ public:
|
|||
|
||||
bool ReadBlock(int blockNumber, u8 *outPtr, bool uncached = false) override;
|
||||
u32 GetNumBlocks() override {return (u32)lbaSize;}
|
||||
bool IsDisc() override { return false; }
|
||||
|
||||
private:
|
||||
FileLoader *fileLoader_;
|
||||
|
|
|
@ -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;
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::FLASH; }
|
||||
u64 FreeSpace(const std::string &path) override { return 0; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -53,6 +53,9 @@ enum DevType {
|
|||
enum class FileSystemFlags {
|
||||
NONE = 0,
|
||||
SIMULATE_FAT32 = 1,
|
||||
UMD = 2,
|
||||
CARD = 4,
|
||||
FLASH = 8,
|
||||
};
|
||||
|
||||
inline FileSystemFlags operator |(const FileSystemFlags &lhs, const FileSystemFlags &rhs) {
|
||||
|
|
|
@ -467,6 +467,12 @@ int ISOFileSystem::DevType(u32 handle)
|
|||
return iter->second.isBlockSectorMode ? PSP_DEV_TYPE_BLOCK : PSP_DEV_TYPE_FILE;
|
||||
}
|
||||
|
||||
FileSystemFlags ISOFileSystem::Flags() {
|
||||
// TODO: Here may be a good place to force things, in case users recompress games
|
||||
// as PBP or CSO when they were originally the other type.
|
||||
return blockDevice->IsDisc() ? FileSystemFlags::UMD : FileSystemFlags::CARD;
|
||||
}
|
||||
|
||||
size_t ISOFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size)
|
||||
{
|
||||
int ignored;
|
||||
|
|
|
@ -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;
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
|
||||
FileSystemFlags Flags() override;
|
||||
u64 FreeSpace(const std::string &path) override { return 0; }
|
||||
|
||||
size_t WriteFile(u32 handle, const u8 *pointer, s64 size) override;
|
||||
|
|
|
@ -56,6 +56,10 @@ public:
|
|||
|
||||
IFileSystem *GetSystem(const std::string &prefix);
|
||||
IFileSystem *GetSystemFromFilename(const std::string &filename);
|
||||
FileSystemFlags FlagsFromFilename(const std::string &filename) {
|
||||
IFileSystem *sys = GetSystemFromFilename(filename);
|
||||
return sys ? sys->Flags() : FileSystemFlags::NONE;
|
||||
}
|
||||
|
||||
void ThreadEnded(int threadID);
|
||||
|
||||
|
|
|
@ -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;
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::UMD; }
|
||||
u64 FreeSpace(const std::string &path) override { return 0; }
|
||||
|
||||
// unsupported operations
|
||||
|
|
|
@ -621,9 +621,9 @@ void __IoInit() {
|
|||
asyncNotifyEvent = CoreTiming::RegisterEvent("IoAsyncNotify", __IoAsyncNotify);
|
||||
syncNotifyEvent = CoreTiming::RegisterEvent("IoSyncNotify", __IoSyncNotify);
|
||||
|
||||
memstickSystem = new DirectoryFileSystem(&pspFileSystem, g_Config.memStickDirectory, FileSystemFlags::SIMULATE_FAT32);
|
||||
memstickSystem = new DirectoryFileSystem(&pspFileSystem, g_Config.memStickDirectory, FileSystemFlags::SIMULATE_FAT32 | FileSystemFlags::CARD);
|
||||
#if defined(USING_WIN_UI) || defined(APPLE)
|
||||
flash0System = new DirectoryFileSystem(&pspFileSystem, g_Config.flash0Directory);
|
||||
flash0System = new DirectoryFileSystem(&pspFileSystem, g_Config.flash0Directory, FileSystemFlags::FLASH);
|
||||
#else
|
||||
flash0System = new VFSFileSystem(&pspFileSystem, "flash0");
|
||||
#endif
|
||||
|
@ -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, FileSystemFlags::SIMULATE_FAT32);
|
||||
exdataSystem = new DirectoryFileSystem(&pspFileSystem, exdataPath, FileSystemFlags::SIMULATE_FAT32 | FileSystemFlags::CARD);
|
||||
pspFileSystem.Mount("exdata0:", exdataSystem);
|
||||
INFO_LOG(SCEIO, "Mounted exdata/%s/ under memstick for exdata0:/", gameId.c_str());
|
||||
} else {
|
||||
|
@ -2287,13 +2287,7 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
|
|||
strncpy(entry->d_name, info.name.c_str(), 256);
|
||||
entry->d_name[255] = '\0';
|
||||
|
||||
bool isFAT = false;
|
||||
IFileSystem *sys = pspFileSystem.GetSystemFromFilename(dir->name);
|
||||
if (sys && (sys->Flags() & FileSystemFlags::SIMULATE_FAT32))
|
||||
isFAT = true;
|
||||
else
|
||||
isFAT = false;
|
||||
|
||||
bool isFAT = pspFileSystem.FlagsFromFilename(dir->name) & FileSystemFlags::SIMULATE_FAT32;
|
||||
// Only write d_private for memory stick
|
||||
if (isFAT) {
|
||||
// write d_private for supporting Custom BGM
|
||||
|
|
|
@ -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, FileSystemFlags::SIMULATE_FAT32);
|
||||
DirectoryFileSystem *fs = new DirectoryFileSystem(&pspFileSystem, path, FileSystemFlags::SIMULATE_FAT32 | FileSystemFlags::CARD);
|
||||
pspFileSystem.Mount("umd0:", fs);
|
||||
|
||||
std::string finalName = ms_path + file + extension;
|
||||
|
|
Loading…
Add table
Reference in a new issue