mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-04-28 20:23:51 +00:00
feat(file): implement stormlib sfile backend (#113)
This commit is contained in:
parent
5472065b8b
commit
b4e950a1c9
3 changed files with 88 additions and 36 deletions
|
|
@ -1,58 +1,51 @@
|
|||
#include "storm/File.hpp"
|
||||
|
||||
// TODO: implement StormLib-backed SFile functions.
|
||||
int32_t StormLib_SFileOpenArchive(const char* archivename, uint32_t priority, uint32_t flags, void** handle);
|
||||
int32_t StormLib_SFileCloseArchive(void* handle);
|
||||
int32_t StormLib_SFileOpenFileEx(void* archivehandle, const char* filename, uint32_t flags, void** handle);
|
||||
int32_t StormLib_SFileReadFile(void* handle, void* buffer, uint32_t bytestoread, uint32_t* bytesread, void* overlapped);
|
||||
uint32_t StormLib_SFileGetFileSize(void* handle, uint32_t* filesizehigh);
|
||||
uint32_t StormLib_SFileSetFilePointer(void* handle, int32_t distancetomove, int32_t* distancetomovehigh, uint32_t movemethod);
|
||||
int32_t StormLib_SFileCloseFile(void* handle);
|
||||
|
||||
int32_t STORMAPI SFileOpenArchive(const char* archivename, int32_t priority, uint32_t flags, HSARCHIVE* handle) {
|
||||
(void)archivename;
|
||||
(void)priority;
|
||||
(void)flags;
|
||||
(void)handle;
|
||||
return 0;
|
||||
if (!handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* archive = nullptr;
|
||||
int32_t result = StormLib_SFileOpenArchive(archivename, static_cast<uint32_t>(priority), flags, &archive);
|
||||
*handle = reinterpret_cast<HSARCHIVE>(archive);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t STORMAPI SFileCloseArchive(HSARCHIVE handle) {
|
||||
(void)handle;
|
||||
return 0;
|
||||
return StormLib_SFileCloseArchive(reinterpret_cast<void*>(handle));
|
||||
}
|
||||
|
||||
int32_t STORMAPI SFileOpenFileEx(HSARCHIVE archivehandle, const char* filename, uint32_t flags, HSFILE* handle) {
|
||||
(void)archivehandle;
|
||||
(void)filename;
|
||||
(void)flags;
|
||||
(void)handle;
|
||||
return 0;
|
||||
if (!handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* file = nullptr;
|
||||
int32_t result = StormLib_SFileOpenFileEx(reinterpret_cast<void*>(archivehandle), filename, flags, &file);
|
||||
*handle = reinterpret_cast<HSFILE>(file);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t STORMAPI SFileReadFile(HSFILE handle, void* buffer, uint32_t bytestoread, uint32_t* bytesread, LPOVERLAPPED overlapped) {
|
||||
(void)handle;
|
||||
(void)buffer;
|
||||
(void)bytestoread;
|
||||
(void)overlapped;
|
||||
if (bytesread) {
|
||||
*bytesread = 0;
|
||||
}
|
||||
return 0;
|
||||
return StormLib_SFileReadFile(reinterpret_cast<void*>(handle), buffer, bytestoread, bytesread, reinterpret_cast<void*>(overlapped));
|
||||
}
|
||||
|
||||
uint32_t STORMAPI SFileGetFileSize(HSFILE handle, uint32_t* filesizehigh) {
|
||||
(void)handle;
|
||||
if (filesizehigh) {
|
||||
*filesizehigh = 0;
|
||||
}
|
||||
return 0;
|
||||
return StormLib_SFileGetFileSize(reinterpret_cast<void*>(handle), filesizehigh);
|
||||
}
|
||||
|
||||
uint32_t STORMAPI SFileSetFilePointer(HSFILE handle, int32_t distancetomove, int32_t* distancetomovehigh, uint32_t movemethod) {
|
||||
(void)handle;
|
||||
(void)distancetomove;
|
||||
(void)movemethod;
|
||||
if (distancetomovehigh) {
|
||||
*distancetomovehigh = 0;
|
||||
}
|
||||
return 0;
|
||||
return StormLib_SFileSetFilePointer(reinterpret_cast<void*>(handle), distancetomove, distancetomovehigh, movemethod);
|
||||
}
|
||||
|
||||
int32_t STORMAPI SFileCloseFile(HSFILE handle) {
|
||||
(void)handle;
|
||||
return 0;
|
||||
return StormLib_SFileCloseFile(reinterpret_cast<void*>(handle));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue