mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-11 09:18:30 +12:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
219
src/Cafe/Filesystem/fsc.h
Normal file
219
src/Cafe/Filesystem/fsc.h
Normal file
|
@ -0,0 +1,219 @@
|
|||
#pragma once
|
||||
|
||||
struct FSCVirtualFile;
|
||||
|
||||
#define FSC_TYPE_INVALID (0)
|
||||
#define FSC_TYPE_FILE (1)
|
||||
#define FSC_TYPE_DIRECTORY (2)
|
||||
|
||||
#define FSC_QUERY_SIZE (1) // file size, 0 for directories
|
||||
#define FSC_QUERY_WRITEABLE (2) // non-zero if file is writeable, else 0
|
||||
|
||||
enum class FSC_ACCESS_FLAG : uint8
|
||||
{
|
||||
NONE = 0,
|
||||
|
||||
// file permissions
|
||||
READ_PERMISSION = (1<<0),
|
||||
WRITE_PERMISSION = (1<<1),
|
||||
|
||||
// file open mode (incompatible with OPEN_DIR flag)
|
||||
FILE_ALLOW_CREATE = (1 << 2), // create file if it does not exist
|
||||
FILE_ALWAYS_CREATE = (1 << 3), // overwrite any existing file
|
||||
|
||||
// which types can be opened
|
||||
// invalid operation if neither is set
|
||||
OPEN_DIR = (1 << 4),
|
||||
OPEN_FILE = (1 << 5)
|
||||
};
|
||||
DEFINE_ENUM_FLAG_OPERATORS(FSC_ACCESS_FLAG);
|
||||
|
||||
#define FSC_STATUS_UNDEFINED (-1)
|
||||
#define FSC_STATUS_OK (0)
|
||||
#define FSC_STATUS_INVALID_PATH (1)
|
||||
#define FSC_STATUS_FILE_NOT_FOUND (2)
|
||||
#define FSC_STATUS_ALREADY_EXISTS (3)
|
||||
// note: Unlike the native Wii U filesystem, FSC does not provide separate error codes for NOT_A_FILE and NOT_A_DIRECTORY
|
||||
// to determine them manually, open with both modes (file and dir) and check the type
|
||||
|
||||
#define FSC_MAX_DIR_NAME_LENGTH (256)
|
||||
#define FSC_MAX_DEVICE_PATH_LENGTH ((std::max)(260,FSA_PATH_SIZE_MAX)) // max length for FSC device paths (should be at least equal or greater than supported by host filesystem)
|
||||
|
||||
struct FSCDirEntry
|
||||
{
|
||||
char path[FSC_MAX_DIR_NAME_LENGTH];
|
||||
// stats
|
||||
bool isDirectory;
|
||||
bool isFile;
|
||||
uint32 fileSize;
|
||||
|
||||
std::string_view GetPath()
|
||||
{
|
||||
size_t len = strnlen(path, FSC_MAX_DIR_NAME_LENGTH);
|
||||
return std::basic_string_view<char>(path, len);
|
||||
}
|
||||
};
|
||||
|
||||
class fscDeviceC
|
||||
{
|
||||
public:
|
||||
virtual FSCVirtualFile* fscDeviceOpenByPath(std::wstring_view path, FSC_ACCESS_FLAG accessFlags, void* ctx, sint32* fscStatus)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual bool fscDeviceCreateDir(std::wstring_view path, void* ctx, sint32* fscStatus)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool fscDeviceRemoveFileOrDir(std::wstring_view path, void* ctx, sint32* fscStatus)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool fscDeviceRename(std::wstring_view srcPath, std::wstring_view dstPath, void* ctx, sint32* fscStatus)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct FSCVirtualFile
|
||||
{
|
||||
struct FSCDirIteratorState
|
||||
{
|
||||
sint32 index;
|
||||
std::vector<FSCDirEntry> dirEntries;
|
||||
};
|
||||
|
||||
FSCVirtualFile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual ~FSCVirtualFile()
|
||||
{
|
||||
if (dirIterator)
|
||||
delete dirIterator;
|
||||
}
|
||||
|
||||
virtual sint32 fscGetType()
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint64 fscQueryValueU64(uint32 id)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint32 fscWriteData(void* buffer, uint32 size)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint32 fscReadData(void* buffer, uint32 size)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void fscSetSeek(uint64 seek)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
}
|
||||
|
||||
virtual uint64 fscGetSeek()
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void fscSetFileLength(uint64 endOffset)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
}
|
||||
|
||||
virtual bool fscDirNext(FSCDirEntry* dirEntry)
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
return false;
|
||||
}
|
||||
|
||||
FSCDirIteratorState* dirIterator{};
|
||||
};
|
||||
|
||||
#define FSC_PRIORITY_BASE (0)
|
||||
#define FSC_PRIORITY_AOC (1)
|
||||
#define FSC_PRIORITY_PATCH (2)
|
||||
#define FSC_PRIORITY_REDIRECT (3)
|
||||
#define FSC_PRIORITY_MAX (3)
|
||||
|
||||
#define FSC_PRIORITY_COUNT (4)
|
||||
|
||||
void fsc_init();
|
||||
sint32 fsc_mount(const char* mountPath, const wchar_t* targetPath, fscDeviceC* fscDevice, void* ctx, sint32 priority=0);
|
||||
bool fsc_unmount(const char* mountPath, sint32 priority);
|
||||
void fsc_unmountAll();
|
||||
|
||||
FSCVirtualFile* fsc_open(const char* path, FSC_ACCESS_FLAG accessFlags, sint32* fscStatus, sint32 maxPriority=FSC_PRIORITY_MAX);
|
||||
FSCVirtualFile* fsc_openDirIterator(const char* path, sint32* fscStatus);
|
||||
bool fsc_createDir(char* path, sint32* fscStatus);
|
||||
bool fsc_rename(char* srcPath, char* dstPath, sint32* fscStatus);
|
||||
bool fsc_remove(char* path, sint32* fscStatus);
|
||||
bool fsc_nextDir(FSCVirtualFile* fscFile, FSCDirEntry* dirEntry);
|
||||
void fsc_close(FSCVirtualFile* fscFile);
|
||||
uint32 fsc_getFileSize(FSCVirtualFile* fscFile);
|
||||
uint32 fsc_getFileSeek(FSCVirtualFile* fscFile);
|
||||
void fsc_setFileSeek(FSCVirtualFile* fscFile, uint32 newSeek);
|
||||
void fsc_setFileLength(FSCVirtualFile* fscFile, uint32 newEndOffset);
|
||||
bool fsc_isDirectory(FSCVirtualFile* fscFile);
|
||||
bool fsc_isFile(FSCVirtualFile* fscFile);
|
||||
bool fsc_isWritable(FSCVirtualFile* fscFile);
|
||||
uint32 fsc_readFile(FSCVirtualFile* fscFile, void* buffer, uint32 size);
|
||||
uint32 fsc_writeFile(FSCVirtualFile* fscFile, void* buffer, uint32 size);
|
||||
|
||||
uint8* fsc_extractFile(const char* path, uint32* fileSize, sint32 maxPriority = FSC_PRIORITY_MAX);
|
||||
std::optional<std::vector<uint8>> fsc_extractFile(const char* path, sint32 maxPriority = FSC_PRIORITY_MAX);
|
||||
bool fsc_doesFileExist(const char* path, sint32 maxPriority = FSC_PRIORITY_MAX);
|
||||
bool fsc_doesDirectoryExist(const char* path, sint32 maxPriority = FSC_PRIORITY_MAX);
|
||||
|
||||
// wud device
|
||||
bool FSCDeviceWUD_Mount(const char* mountPath, std::string_view destinationBaseDir, class FSTVolume* mountedVolume, sint32 priority);
|
||||
|
||||
// wua device
|
||||
bool FSCDeviceWUA_Mount(const char* mountPath, std::string_view destinationBaseDir, class ZArchiveReader* archive, sint32 priority);
|
||||
|
||||
// hostFS device
|
||||
void fscDeviceHostFS_mapBaseDirectories_deprecated();
|
||||
bool FSCDeviceHostFS_Mount(const char* mountPath, const wchar_t* hostFSPath, sint32 priority);
|
||||
|
||||
// redirect device
|
||||
void fscDeviceRedirect_map();
|
||||
void fscDeviceRedirect_add(std::string_view virtualSourcePath, const fs::path& targetFilePath, sint32 priority);
|
||||
|
||||
|
||||
// Old path parser helper functions
|
||||
// Replace with FSCPath
|
||||
|
||||
#define FSC_PARSED_PATH_NODES_MAX (32)
|
||||
|
||||
struct CoreinitFSParsedPath
|
||||
{
|
||||
char pathData[640 + 1];
|
||||
uint16 nodeOffset[FSC_PARSED_PATH_NODES_MAX];
|
||||
sint32 numNodes;
|
||||
};
|
||||
|
||||
void coreinitFS_parsePath(CoreinitFSParsedPath* parsedPath, const char* path);
|
||||
bool coreinitFS_checkNodeName(CoreinitFSParsedPath* parsedPath, sint32 index, const char* name);
|
||||
char* coreinitFS_getNodeName(CoreinitFSParsedPath* parsedPath, sint32 index);
|
Loading…
Add table
Add a link
Reference in a new issue