mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Added fsExit and fsGetServiceSession. Check whether initialization was already done in fsInitialize, etc. Added fs to __appInit/__appExit.
This commit is contained in:
parent
6280e1ba58
commit
68dbb72b04
@ -26,6 +26,10 @@ typedef enum {
|
|||||||
#define FS_MAX_PATH 0x301
|
#define FS_MAX_PATH 0x301
|
||||||
|
|
||||||
Result fsInitialize();
|
Result fsInitialize();
|
||||||
|
void fsExit(void);
|
||||||
|
|
||||||
|
Handle fsGetServiceSession(void);
|
||||||
|
|
||||||
Result fsMountSdcard(FsFileSystem* out);
|
Result fsMountSdcard(FsFileSystem* out);
|
||||||
// todo: Rest of commands here
|
// todo: Rest of commands here
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// Copyright 2017 plutoo
|
// Copyright 2017 plutoo
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
static Handle g_fsHandle = -1;
|
static Handle g_fsHandle = INVALID_HANDLE;
|
||||||
|
|
||||||
Result fsInitialize() {
|
Result fsInitialize() {
|
||||||
|
if(g_fsHandle != INVALID_HANDLE)return 0;
|
||||||
Result rc = smGetService(&g_fsHandle, "fsp-srv");
|
Result rc = smGetService(&g_fsHandle, "fsp-srv");
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
@ -41,6 +42,16 @@ Result fsInitialize() {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fsExit(void) {
|
||||||
|
if(g_fsHandle == INVALID_HANDLE)return;
|
||||||
|
svcCloseHandle(g_fsHandle);
|
||||||
|
g_fsHandle = INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle fsGetServiceSession(void) {
|
||||||
|
return g_fsHandle;
|
||||||
|
}
|
||||||
|
|
||||||
Result fsMountSdcard(FsFileSystem* out) {
|
Result fsMountSdcard(FsFileSystem* out) {
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
|
@ -31,11 +31,13 @@ void __attribute__((weak)) __appInit(void)
|
|||||||
{
|
{
|
||||||
// Initialize default services.
|
// Initialize default services.
|
||||||
smInitialize();
|
smInitialize();
|
||||||
|
fsInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((weak)) __appExit(void)
|
void __attribute__((weak)) __appExit(void)
|
||||||
{
|
{
|
||||||
// Cleanup default services.
|
// Cleanup default services.
|
||||||
|
fsExit();
|
||||||
smExit();
|
smExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user