mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
parent
d3889fb9ed
commit
1abfb02460
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "../nacp.h"
|
||||
#include "../services/fs.h"
|
||||
|
||||
typedef struct {
|
||||
NacpStruct nacp;
|
||||
@ -18,6 +19,20 @@ void nsExit(void);
|
||||
|
||||
Result nsGetApplicationControlData(u8 flag, u64 titleID, NsApplicationControlData* buffer, size_t size, size_t* actual_size);
|
||||
|
||||
/**
|
||||
* @brief Returns the total storage capacity (used + free) from content manager services.
|
||||
* @param storage_id Specified FsStorageId. (Must be FsStorageId_SdCard)
|
||||
* @param size Pointer to output the total storage size to.
|
||||
*/
|
||||
Result nsGetTotalSpaceSize(FsStorageId storage_id, u64 *size);
|
||||
|
||||
/**
|
||||
* @brief Returns the available storage capacity from content manager services.
|
||||
* @param storage_id Specified FsStorageId. (Must be FsStorageId_SdCard)
|
||||
* @param size Pointer to output the free storage size to.
|
||||
*/
|
||||
Result nsGetFreeSpaceSize(FsStorageId storage_id, u64 *size);
|
||||
|
||||
Result nsvmInitialize(void);
|
||||
void nsvmExit(void);
|
||||
|
||||
|
@ -117,6 +117,80 @@ Result nsGetApplicationControlData(u8 flag, u64 titleID, NsApplicationControlDat
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsGetTotalSpaceSize(FsStorageId storage_id, u64 *size)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 storage_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 47;
|
||||
raw->storage_id = storage_id;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nsAppManSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u64 size;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && size) *size = resp->size;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsGetFreeSpaceSize(FsStorageId storage_id, u64 *size)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 storage_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 48;
|
||||
raw->storage_id = storage_id;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nsAppManSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u64 size;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && size) *size = resp->size;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsvmInitialize(void)
|
||||
{
|
||||
if (!kernelAbove300())
|
||||
|
Loading…
Reference in New Issue
Block a user