Added fsExit and fsGetServiceSession. Check whether initialization was already done in fsInitialize, etc. Added fs to __appInit/__appExit.

This commit is contained in:
yellows8 2017-10-14 21:45:59 -04:00
parent 6280e1ba58
commit 68dbb72b04
3 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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);

View File

@ -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();
} }