mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-05-04 06:33:50 +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
58
storm/file/SFileStormLibShim.cpp
Normal file
58
storm/file/SFileStormLibShim.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#include "StormLib.h"
|
||||
#include <cstdint>
|
||||
|
||||
int32_t StormLib_SFileOpenArchive(const char* archivename, uint32_t priority, uint32_t flags, void** handle) {
|
||||
if (!handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
HANDLE archive = nullptr;
|
||||
bool result = SFileOpenArchive(archivename, static_cast<DWORD>(priority), static_cast<DWORD>(flags), &archive);
|
||||
*handle = archive;
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t StormLib_SFileCloseArchive(void* handle) {
|
||||
return SFileCloseArchive(static_cast<HANDLE>(handle));
|
||||
}
|
||||
|
||||
int32_t StormLib_SFileOpenFileEx(void* archivehandle, const char* filename, uint32_t flags, void** handle) {
|
||||
if (!handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
HANDLE file = nullptr;
|
||||
bool result = SFileOpenFileEx(static_cast<HANDLE>(archivehandle), filename, static_cast<DWORD>(flags), &file);
|
||||
*handle = file;
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t StormLib_SFileReadFile(void* handle, void* buffer, uint32_t bytestoread, uint32_t* bytesread, void* overlapped) {
|
||||
return SFileReadFile(
|
||||
static_cast<HANDLE>(handle),
|
||||
buffer,
|
||||
static_cast<DWORD>(bytestoread),
|
||||
reinterpret_cast<LPDWORD>(bytesread),
|
||||
reinterpret_cast<LPOVERLAPPED>(overlapped)
|
||||
);
|
||||
}
|
||||
|
||||
uint32_t StormLib_SFileGetFileSize(void* handle, uint32_t* filesizehigh) {
|
||||
return SFileGetFileSize(
|
||||
static_cast<HANDLE>(handle),
|
||||
reinterpret_cast<LPDWORD>(filesizehigh)
|
||||
);
|
||||
}
|
||||
|
||||
uint32_t StormLib_SFileSetFilePointer(void* handle, int32_t distancetomove, int32_t* distancetomovehigh, uint32_t movemethod) {
|
||||
return SFileSetFilePointer(
|
||||
static_cast<HANDLE>(handle),
|
||||
static_cast<LONG>(distancetomove),
|
||||
reinterpret_cast<PLONG>(distancetomovehigh),
|
||||
static_cast<DWORD>(movemethod)
|
||||
);
|
||||
}
|
||||
|
||||
int32_t StormLib_SFileCloseFile(void* handle) {
|
||||
return SFileCloseFile(static_cast<HANDLE>(handle));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue