2021-01-01 01:39:28 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <functional>
|
|
|
|
#include <coreinit/filesystem.h>
|
|
|
|
#include <coreinit/mutex.h>
|
|
|
|
|
|
|
|
typedef struct dirMagic {
|
|
|
|
uint32_t handle;
|
|
|
|
DIR *dir;
|
|
|
|
bool in_use;
|
2021-04-05 19:54:50 +02:00
|
|
|
char path[256];
|
2021-01-01 01:39:28 +01:00
|
|
|
OSMutex *mutex;
|
|
|
|
} dirMagic_t;
|
|
|
|
|
|
|
|
typedef struct fileMagic {
|
|
|
|
uint32_t handle;
|
|
|
|
bool in_use;
|
|
|
|
int fd;
|
|
|
|
OSMutex *mutex;
|
|
|
|
} fileMagic_t;
|
|
|
|
|
|
|
|
#define HANDLE_INDICATOR_MASK 0xFFFFFF00
|
|
|
|
#define HANDLE_MASK (0x000000FF)
|
|
|
|
#define DIR_HANDLE_MAGIC 0x30000000
|
|
|
|
#define FILE_HANDLE_MAGIC 0x30000100
|
|
|
|
|
|
|
|
#define FILE_HANDLES_LENGTH 64
|
|
|
|
#define DIR_HANDLES_LENGTH 64
|
|
|
|
|
|
|
|
#define FS_STATUS_USE_REAL_OS (FSStatus) 0xFFFF0000
|
|
|
|
|
|
|
|
extern dirMagic_t dir_handles[DIR_HANDLES_LENGTH];
|
|
|
|
extern fileMagic_t file_handles[FILE_HANDLES_LENGTH];
|
|
|
|
|
|
|
|
FSStatus FSOpenDirWrapper(char *path,
|
|
|
|
FSDirectoryHandle *handle,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(char *)>& fallback_function,
|
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
|
|
|
FSDirectoryEntry *entry,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSMakeDirWrapper(char *path,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(char *)>& fallback_function,
|
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSOpenFileWrapper(char *path,
|
|
|
|
const char *mode,
|
|
|
|
FSFileHandle *handle,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(char *)>& fallback_function,
|
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSGetStatWrapper(char *path,
|
|
|
|
FSStat *stats,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(char *)>& fallback_function,
|
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSGetStatFileWrapper(FSFileHandle handle,
|
|
|
|
FSStat *stats,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSReadFileWrapper(void *buffer,
|
|
|
|
uint32_t size,
|
|
|
|
uint32_t count,
|
|
|
|
FSFileHandle handle,
|
|
|
|
uint32_t unk1,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSReadFileWithPosWrapper(void *buffer,
|
|
|
|
uint32_t size,
|
|
|
|
uint32_t count,
|
|
|
|
uint32_t pos,
|
|
|
|
FSFileHandle handle,
|
|
|
|
int32_t unk1,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSSetPosFileWrapper(FSFileHandle handle,
|
|
|
|
uint32_t pos,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSGetPosFileWrapper(FSFileHandle handle,
|
|
|
|
uint32_t *pos,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSIsEofWrapper(FSFileHandle handle,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSTruncateFileWrapper(FSFileHandle handle,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSWriteFileWrapper(uint8_t *buffer,
|
|
|
|
uint32_t size,
|
|
|
|
uint32_t count,
|
|
|
|
FSFileHandle handle,
|
|
|
|
uint32_t unk1,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSRemoveWrapper(char *path,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(char *)>& fallback_function,
|
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSRenameWrapper(char *oldPath,
|
|
|
|
char *newPath,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(char *, char *)>& fallback_function,
|
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
FSStatus FSFlushFileWrapper(FSFileHandle handle,
|
|
|
|
FSErrorFlag errorMask,
|
2021-09-24 17:14:38 +02:00
|
|
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
|
|
|
int32_t getNewDirHandleIndex();
|
|
|
|
|
|
|
|
int32_t getNewFileHandleIndex();
|
|
|
|
|
|
|
|
bool isValidDirHandle(int32_t handle);
|
|
|
|
|
|
|
|
bool isValidFileHandle(int32_t handle);
|