mirror of
https://github.com/wiiu-env/libsdutils.git
synced 2024-11-22 02:59:15 +01:00
Use latest SDUtilsGetVersion implementation
This commit is contained in:
parent
2e4b78d3ed
commit
170c43fcba
@ -19,7 +19,7 @@ enum SDUtilsStatus {
|
||||
};
|
||||
|
||||
typedef uint32_t SDUtilsVersion;
|
||||
#define SDUTILS_MODULE_VERSION 0x00000001
|
||||
#define SD_UTILS_MODULE_VERSION_ERROR 0xFFFFFFFF
|
||||
|
||||
enum SDUtilsAttachStatus {
|
||||
SDUTILS_ATTACH_MOUNTED = 1,
|
||||
@ -45,11 +45,17 @@ SDUtilsStatus SDUtils_InitLibrary();
|
||||
SDUtilsStatus SDUtils_DeInitLibrary();
|
||||
|
||||
/**
|
||||
* Returns the API Version of the WUHBUtils Module.
|
||||
* @return The WUHBUtilsVersion of the Module
|
||||
* Retrieves the API Version of the loaded SDUtils.<br>
|
||||
* <br>
|
||||
* @param outVersion pointer to the variable where the version will be stored.
|
||||
*
|
||||
* @return SDUTILS_RESULT_SUCCESS: The API version has been store in the version ptr.<br>
|
||||
* SDUTILS_RESULT_MODULE_NOT_FOUND: The module could not be found. Make sure the module is loaded.<br>
|
||||
* SDUTILS_RESULT_MODULE_MISSING_EXPORT: The module is missing an expected export.<br>
|
||||
* SDUTILS_RESULT_INVALID_ARGUMENT: Invalid version pointer.<br>
|
||||
* SDUTILS_RESULT_UNKNOWN_ERROR: Retrieving the module version failed.
|
||||
*/
|
||||
SDUtilsVersion SDUtils_GetVersion();
|
||||
|
||||
SDUtilsStatus SDUtils_GetVersion(SDUtilsVersion *outVersion);
|
||||
|
||||
/**
|
||||
* Registers a callback which will be called whenever a sd card will be inserted or ejected.
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
static OSDynLoad_Module sModuleHandle = nullptr;
|
||||
|
||||
static SDUtilsVersion (*sSDUtilsGetVersion)() = nullptr;
|
||||
static SDUtilsStatus (*sSDUtilsGetVersion)(SDUtilsVersion *) = nullptr;
|
||||
|
||||
static bool (*sSDUtilsAddAttachHandler)(SDAttachHandlerFn) = nullptr;
|
||||
static bool (*sSDUtilsRemoveAttachHandler)(SDAttachHandlerFn) = nullptr;
|
||||
@ -13,6 +13,8 @@ static bool (*sSDUtilsRemoveAttachHandler)(SDAttachHandlerFn) = nullptr;
|
||||
static bool (*sSDUtilsAddCleanUpHandlesHandler)(SDCleanUpHandlesHandlerFn) = nullptr;
|
||||
static bool (*sSDUtilsRemoveCleanUpHandlesHandler)(SDCleanUpHandlesHandlerFn) = nullptr;
|
||||
|
||||
static SDUtilsVersion sSDUtilsVersion = SD_UTILS_MODULE_VERSION_ERROR;
|
||||
|
||||
SDUtilsStatus SDUtils_InitLibrary() {
|
||||
if (OSDynLoad_Acquire("homebrew_sdhotswap", &sModuleHandle) != OS_DYNLOAD_OK) {
|
||||
OSReport("SDUtils_Init: OSDynLoad_Acquire failed.\n");
|
||||
@ -23,8 +25,9 @@ SDUtilsStatus SDUtils_InitLibrary() {
|
||||
OSReport("SDUtils_Init: SDUtilsGetVersion failed.\n");
|
||||
return SDUTILS_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
auto res = SDUtils_GetVersion();
|
||||
if (res != SDUTILS_MODULE_VERSION) {
|
||||
|
||||
auto res = SDUtils_GetVersion(&sSDUtilsVersion);
|
||||
if (res != SDUTILS_RESULT_SUCCESS) {
|
||||
return SDUTILS_RESULT_UNSUPPORTED_VERSION;
|
||||
}
|
||||
|
||||
@ -56,13 +59,12 @@ SDUtilsStatus SDUtils_DeInitLibrary() {
|
||||
return SDUTILS_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
SDUtilsVersion GetVersion();
|
||||
SDUtilsVersion SDUtils_GetVersion() {
|
||||
if (sSDUtilsGetVersion == nullptr) {
|
||||
return SDUTILS_RESULT_LIB_UNINITIALIZED;
|
||||
SDUtilsStatus GetVersion(SDUtilsVersion *);
|
||||
SDUtilsStatus SDUtils_GetVersion(SDUtilsVersion *version) {
|
||||
if (version == nullptr) {
|
||||
return SDUTILS_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return reinterpret_cast<decltype(&GetVersion)>(sSDUtilsGetVersion)();
|
||||
return reinterpret_cast<decltype(&GetVersion)>(sSDUtilsGetVersion)(version);
|
||||
}
|
||||
|
||||
SDUtilsStatus SDUtils_IsSdCardMounted(bool *status) {
|
||||
|
Loading…
Reference in New Issue
Block a user