mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-13 06:42:38 +01:00
whb: Add SD card mounting support.
This commit is contained in:
parent
fb325ec894
commit
b79a58dec2
27
src/libwhb/include/whb/sdcard.h
Normal file
27
src/libwhb/include/whb/sdcard.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_sdcard SDCard Access
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
WHBMountSdCard();
|
||||
|
||||
char *
|
||||
WHBGetSdCardMountPath();
|
||||
|
||||
BOOL
|
||||
WHBUnmountSdCard();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
78
src/libwhb/src/sdcard.c
Normal file
78
src/libwhb/src/sdcard.c
Normal file
@ -0,0 +1,78 @@
|
||||
#include <coreinit/filesystem.h>
|
||||
#include <whb/sdcard.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
static BOOL
|
||||
sMounted = FALSE;
|
||||
|
||||
static char
|
||||
sMountPath[128] = { 0 };
|
||||
|
||||
static FSClient
|
||||
sClient;
|
||||
|
||||
BOOL
|
||||
WHBMountSdCard()
|
||||
{
|
||||
FSCmdBlock cmd;
|
||||
FSMountSource mountSource;
|
||||
FSStatus result;
|
||||
|
||||
if (sMounted) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
FSInit();
|
||||
|
||||
result = FSAddClient(&sClient, -1);
|
||||
if (result != FS_STATUS_OK) {
|
||||
WHBLogPrintf("%s: FSAddClient error %d", __FUNCTION__, result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
FSInitCmdBlock(&cmd);
|
||||
result = FSGetMountSource(&sClient, &cmd, FS_MOUNT_SOURCE_SD, &mountSource, -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSGetMountSource error %d", __FUNCTION__, result);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
result = FSMount(&sClient, &cmd, &mountSource, sMountPath, sizeof(sMountPath), -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSMount error %d", __FUNCTION__, result);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sMounted = TRUE;
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
FSDelClient(&sClient, -1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char *
|
||||
WHBGetSdCardMountPath()
|
||||
{
|
||||
return sMountPath;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBUnmountSdCard()
|
||||
{
|
||||
FSCmdBlock cmd;
|
||||
FSStatus result;
|
||||
|
||||
if (!sMounted) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
result = FSUnmount(&sClient, &cmd, sMountPath, -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSUnmount error %d", __FUNCTION__, result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sMounted = FALSE;
|
||||
return TRUE;
|
||||
}
|
Loading…
Reference in New Issue
Block a user