mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-03 16:39:08 +00:00
chore(file): add sfile/sfilenative backend selection
This commit is contained in:
parent
fb141ff527
commit
a4dec308c2
4 changed files with 126 additions and 0 deletions
|
|
@ -18,6 +18,9 @@ project(storm)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
set(WHOA_SFILE_MODE "NATIVE" CACHE STRING "SFile backend (NATIVE or STORMLIB)")
|
||||||
|
set_property(CACHE WHOA_SFILE_MODE PROPERTY STRINGS NATIVE STORMLIB)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH
|
list(APPEND CMAKE_MODULE_PATH
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/lib/system/cmake"
|
"${CMAKE_CURRENT_SOURCE_DIR}/lib/system/cmake"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/cmake-modules"
|
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/cmake-modules"
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,18 @@ if(WHOA_SYSTEM_LINUX)
|
||||||
list(APPEND STORM_SOURCES ${STORM_LINUX_SOURCES})
|
list(APPEND STORM_SOURCES ${STORM_LINUX_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WHOA_SFILE_MODE STREQUAL "STORMLIB")
|
||||||
|
list(APPEND STORM_SOURCES "file/SFile.cpp")
|
||||||
|
else()
|
||||||
|
list(APPEND STORM_SOURCES "file/SFileNative.cpp")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(storm STATIC
|
add_library(storm STATIC
|
||||||
${STORM_SOURCES}
|
${STORM_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(storm PRIVATE _CRT_SECURE_NO_WARNINGS)
|
target_compile_definitions(storm PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
|
target_compile_definitions(storm PUBLIC WHOA_SFILE_MODE_${WHOA_SFILE_MODE})
|
||||||
|
|
||||||
target_include_directories(storm
|
target_include_directories(storm
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
|
|
||||||
58
storm/file/SFile.cpp
Normal file
58
storm/file/SFile.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include "storm/File.hpp"
|
||||||
|
|
||||||
|
// TODO: implement StormLib-backed SFile functions.
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t STORMAPI SFileCloseArchive(HSARCHIVE handle) {
|
||||||
|
(void)handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t STORMAPI SFileOpenFileEx(HSARCHIVE archivehandle, const char* filename, uint32_t flags, HSFILE* handle) {
|
||||||
|
(void)archivehandle;
|
||||||
|
(void)filename;
|
||||||
|
(void)flags;
|
||||||
|
(void)handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t STORMAPI SFileGetFileSize(HSFILE handle, uint32_t* filesizehigh) {
|
||||||
|
(void)handle;
|
||||||
|
if (filesizehigh) {
|
||||||
|
*filesizehigh = 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t STORMAPI SFileCloseFile(HSFILE handle) {
|
||||||
|
(void)handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
58
storm/file/SFileNative.cpp
Normal file
58
storm/file/SFileNative.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include "storm/File.hpp"
|
||||||
|
|
||||||
|
// TODO: implement native filesystem-backed SFile functions. same functionality as whoa's SFile?
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t STORMAPI SFileCloseArchive(HSARCHIVE handle) {
|
||||||
|
(void)handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t STORMAPI SFileOpenFileEx(HSARCHIVE archivehandle, const char* filename, uint32_t flags, HSFILE* handle) {
|
||||||
|
(void)archivehandle;
|
||||||
|
(void)filename;
|
||||||
|
(void)flags;
|
||||||
|
(void)handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t STORMAPI SFileGetFileSize(HSFILE handle, uint32_t* filesizehigh) {
|
||||||
|
(void)handle;
|
||||||
|
if (filesizehigh) {
|
||||||
|
*filesizehigh = 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t STORMAPI SFileCloseFile(HSFILE handle) {
|
||||||
|
(void)handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue