2022-04-14 22:41:41 +02:00
|
|
|
#pragma once
|
2022-09-10 21:24:58 +02:00
|
|
|
#include <coreinit/filesystem_fsa.h>
|
2022-04-14 22:41:41 +02:00
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
#define FS_ERROR_EXTRA_MASK 0xFFF00000
|
|
|
|
#define FS_ERROR_REAL_MASK 0x000FFFFF
|
|
|
|
#define FS_ERROR_FORCE_PARENT_LAYER (FSError) 0xFFE00000
|
|
|
|
#define FS_ERROR_FORCE_NO_FALLBACK (FSError) 0xFFD00000
|
|
|
|
#define FS_ERROR_FORCE_REAL_FUNCTION (FSError) 0xFFC00000
|
2022-04-14 22:41:41 +02:00
|
|
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
|
|
|
|
|
|
|
class IFSWrapper {
|
|
|
|
public:
|
|
|
|
virtual ~IFSWrapper() = default;
|
2022-08-07 19:22:20 +02:00
|
|
|
virtual FSError FSOpenDirWrapper(const char *path,
|
2022-09-10 21:24:58 +02:00
|
|
|
FSADirectoryHandle *handle) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSReadDirWrapper(FSADirectoryHandle handle,
|
|
|
|
FSADirectoryEntry *entry) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSCloseDirWrapper(FSADirectoryHandle handle) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSRewindDirWrapper(FSADirectoryHandle handle) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-07 19:22:20 +02:00
|
|
|
virtual FSError FSMakeDirWrapper(const char *path) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-07 19:22:20 +02:00
|
|
|
virtual FSError FSOpenFileWrapper(const char *path,
|
|
|
|
const char *mode,
|
2022-09-10 21:24:58 +02:00
|
|
|
FSAFileHandle *handle) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSCloseFileWrapper(FSAFileHandle handle) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-07 19:22:20 +02:00
|
|
|
virtual FSError FSGetStatWrapper(const char *path,
|
2022-09-10 21:24:58 +02:00
|
|
|
FSAStat *stats) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSGetStatFileWrapper(FSAFileHandle handle,
|
|
|
|
FSAStat *stats) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-07 19:22:20 +02:00
|
|
|
virtual FSError FSReadFileWrapper(void *buffer,
|
|
|
|
uint32_t size,
|
|
|
|
uint32_t count,
|
2022-09-10 21:24:58 +02:00
|
|
|
FSAFileHandle handle,
|
2022-08-07 19:22:20 +02:00
|
|
|
uint32_t unk1) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-07 19:22:20 +02:00
|
|
|
virtual FSError FSReadFileWithPosWrapper(void *buffer,
|
|
|
|
uint32_t size,
|
|
|
|
uint32_t count,
|
|
|
|
uint32_t pos,
|
2022-09-10 21:24:58 +02:00
|
|
|
FSAFileHandle handle,
|
2022-08-07 19:22:20 +02:00
|
|
|
int32_t unk1) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSSetPosFileWrapper(FSAFileHandle handle,
|
2022-08-07 19:22:20 +02:00
|
|
|
uint32_t pos) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSGetPosFileWrapper(FSAFileHandle handle,
|
2022-08-07 19:22:20 +02:00
|
|
|
uint32_t *pos) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSIsEofWrapper(FSAFileHandle handle) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSTruncateFileWrapper(FSAFileHandle handle) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSWriteFileWrapper(const uint8_t *buffer,
|
2022-08-07 19:22:20 +02:00
|
|
|
uint32_t size,
|
|
|
|
uint32_t count,
|
2022-09-10 21:24:58 +02:00
|
|
|
FSAFileHandle handle,
|
2022-08-07 19:22:20 +02:00
|
|
|
uint32_t unk1) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSWriteFileWithPosWrapper(const uint8_t *buffer,
|
|
|
|
uint32_t size,
|
|
|
|
uint32_t count,
|
|
|
|
FSAFilePosition pos,
|
|
|
|
FSAFileHandle handle,
|
|
|
|
uint32_t unk1) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
|
|
|
}
|
|
|
|
|
2022-08-07 19:22:20 +02:00
|
|
|
virtual FSError FSRemoveWrapper(const char *path) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-07 19:22:20 +02:00
|
|
|
virtual FSError FSRenameWrapper(const char *oldPath,
|
|
|
|
const char *newPath) {
|
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual FSError FSFlushFileWrapper(FSAFileHandle handle) {
|
2022-08-07 19:22:20 +02:00
|
|
|
return FS_ERROR_FORCE_PARENT_LAYER;
|
2022-04-14 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool fallbackOnError() {
|
|
|
|
return pFallbackOnError;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isActive() {
|
|
|
|
return pIsActive;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setActive(bool newValue) {
|
|
|
|
pIsActive = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] virtual std::string getName() const {
|
|
|
|
return pName;
|
|
|
|
}
|
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual bool isValidDirHandle(FSADirectoryHandle handle) = 0;
|
|
|
|
|
|
|
|
virtual bool isValidFileHandle(FSAFileHandle handle) = 0;
|
2022-04-14 22:41:41 +02:00
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual void deleteDirHandle(FSADirectoryHandle handle) = 0;
|
2022-04-14 22:41:41 +02:00
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual void deleteFileHandle(FSAFileHandle handle) = 0;
|
2022-04-14 22:41:41 +02:00
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual uint32_t getLayerId() = 0;
|
2022-04-14 22:41:41 +02:00
|
|
|
|
2022-09-10 21:24:58 +02:00
|
|
|
virtual uint32_t getHandle() {
|
2022-04-29 13:34:04 +02:00
|
|
|
return (uint32_t) this;
|
|
|
|
}
|
|
|
|
|
2022-04-14 22:41:41 +02:00
|
|
|
private:
|
|
|
|
bool pIsActive = true;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool pFallbackOnError = false;
|
|
|
|
std::string pName;
|
|
|
|
};
|
|
|
|
#pragma GCC diagnostic pop
|