From 01fb4218ba209308a793b7e9915964b70b79f2fe Mon Sep 17 00:00:00 2001 From: Rajko Stojadinovic Date: Thu, 26 Jul 2018 06:10:17 +0200 Subject: [PATCH] Add ncmContentStorageGetPlaceHolderPath and ncmContentStorageCleanupAllPlaceHolder --- nx/include/switch/services/ncm.h | 2 + nx/source/services/ncm.c | 69 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/nx/include/switch/services/ncm.h b/nx/include/switch/services/ncm.h index cd2f9cbd..2ddb42e4 100644 --- a/nx/include/switch/services/ncm.h +++ b/nx/include/switch/services/ncm.h @@ -75,6 +75,8 @@ Result ncmContentStorageRegister(NcmContentStorage* cs, const NcmNcaId* register Result ncmContentStorageDelete(NcmContentStorage* cs, const NcmNcaId* registeredId); Result ncmContentStorageHas(NcmContentStorage* cs, const NcmNcaId* ncaId, bool* out); Result ncmContentStorageGetPath(NcmContentStorage* cs, const NcmNcaId* ncaId, char* out, size_t outSize); +Result ncmContentStorageGetPlaceHolderPath(NcmContentStorage* cs, const NcmNcaId* ncaId, char* out, size_t outSize); +Result ncmContentStorageCleanupAllPlaceHolder(NcmContentStorage* cs); Result ncmContentStorageGetSize(NcmContentStorage* cs, const NcmNcaId* ncaId, u64* out); Result ncmContentStorageDisableForcibly(NcmContentStorage* cs); Result ncmContentStorageReadContentIdFile(NcmContentStorage* cs, const NcmNcaId* ncaId, u64 offset, void* outBuf, size_t bufSize); diff --git a/nx/source/services/ncm.c b/nx/source/services/ncm.c index 584cdf2f..bdf96b00 100644 --- a/nx/source/services/ncm.c +++ b/nx/source/services/ncm.c @@ -371,6 +371,75 @@ Result ncmContentStorageGetPath(NcmContentStorage* cs, const NcmNcaId* ncaId, ch return rc; } +Result ncmContentStorageGetPlaceHolderPath(NcmContentStorage* cs, const NcmNcaId* ncaId, char* out, size_t outSize) { + char out_path[FS_MAX_PATH-1] = {0}; + IpcCommand c; + ipcInitialize(&c); + ipcAddRecvStatic(&c, out_path, FS_MAX_PATH-1, 0); + + struct { + u64 magic; + u64 cmd_id; + NcmNcaId nca_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + raw->magic = SFCI_MAGIC; + raw->cmd_id = 9; + memcpy(&raw->nca_id, ncaId, sizeof(NcmNcaId)); + + Result rc = serviceIpcDispatch(&cs->s); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + } *resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc)) { + if (outSize > FS_MAX_PATH-1) outSize = FS_MAX_PATH-1; + strncpy(out, out_path, outSize); + } + } + + return rc; +} + +Result ncmContentStorageCleanupAllPlaceHolder(NcmContentStorage* cs) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + raw->magic = SFCI_MAGIC; + raw->cmd_id = 10; + + Result rc = serviceIpcDispatch(&cs->s); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + } *resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + Result ncmContentStorageGetSize(NcmContentStorage* cs, const NcmNcaId* ncaId, u64* out) { IpcCommand c; ipcInitialize(&c);