Skip to content

Commit

Permalink
ns: Added nsEstimateSizeToMove.
Browse files Browse the repository at this point in the history
  • Loading branch information
yellows8 committed Oct 20, 2023
1 parent 4ff1c52 commit 94cfa2b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nx/include/switch/services/ns.h
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,18 @@ Result nsIsAnyApplicationEntityInstalled(u64 application_id, bool *out);
*/
Result nsCleanupUnavailableAddOnContents(u64 application_id, AccountUid uid);

/**
* @brief EstimateSizeToMove
* @note Only available on [10.0.0+].
* @param[in] storage_ids Array of u8 \ref NcmStorageId.
* @param[in] count Size of the storage_ids array in entries.
* @param[in] storage_id storage_id \ref NcmStorageId
* @param[in] flags Flags
* @param[in] application_id ApplicationId.
* @param[out] Out Output value.
*/
Result nsEstimateSizeToMove(u8 *storage_ids, s32 count, NcmStorageId storage_id, u32 flags, u64 application_id, s64 *out);

/**
* @brief FormatSdCard
* @note Only available on [2.0.0+].
Expand Down
23 changes: 23 additions & 0 deletions nx/source/services/ns.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,29 @@ Result nsCleanupUnavailableAddOnContents(u64 application_id, AccountUid uid) {
return rc;
}

Result nsEstimateSizeToMove(u8 *storage_ids, s32 count, NcmStorageId storage_id, u32 flags, u64 application_id, s64 *out) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

Service srv={0};
Result rc = nsGetApplicationManagerInterface(&srv);

const struct {
u8 storage_id;
u8 pad[3];
u32 flags;
u64 application_id;
} in = { storage_id, {0}, flags, application_id };

if (R_SUCCEEDED(rc)) rc = serviceDispatchInOut(&srv, 1311, in, *out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { storage_ids, count*sizeof(u8) } },
);

serviceClose(&srv);
return rc;
}

Result nsFormatSdCard(void) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Expand Down

0 comments on commit 94cfa2b

Please sign in to comment.