fix query and use count instead of size for listing

This commit is contained in:
HookedBehemoth 2020-01-14 19:13:21 +01:00
parent 9c79de1844
commit 8180ce9046
3 changed files with 32 additions and 26 deletions

View File

@ -189,6 +189,12 @@ typedef struct {
u8 unk_x50[0x400]; ///< Unused.
} CapsLoadAlbumScreenShotImageOutput;
/// AlbumFileContentsFlag
typedef enum {
CapsAlbumFileContentsFlag_ScreenShot = BIT(0), ///< Query for ScreenShot files.
CapsAlbumFileContentsFlag_Movie = BIT(1), ///< Query for Movie files.
} CapsAlbumFileContentsFlag;
/// AlbumCache
typedef struct {
u64 count; ///< Count

View File

@ -31,11 +31,11 @@ Result capsaGetAlbumFileCount(CapsAlbumStorage storage, u64 *count);
/**
* @brief Gets a listing of \ref CapsAlbumEntry, where the AlbumFile's storage matches the input one.
* @param[in] storage \ref CapsAlbumStorage
* @param[out] count Total output entries.
* @param[out] out Total output entries.
* @param[out] entries Output array of \ref CapsAlbumEntry.
* @param[in] size Reserved size at entries
* @param[in] count Reserved entry count.
*/
Result capsaGetAlbumFileList(CapsAlbumStorage storage, u64 *count, CapsAlbumEntry *entries, u64 size);
Result capsaGetAlbumFileList(CapsAlbumStorage storage, u64 *out, CapsAlbumEntry *entries, u64 count);
/**
* @brief Loads a file into the specified buffer.
@ -195,21 +195,21 @@ Result capsaGetMinMaxAppletId(bool* success, u64* min, u64* max);
* @brief Gets the amount of files of the specified type at a AlbumStorage.
* @note Only available on [5.0.0+].
* @param[in] storage \ref CapsAlbumStorage
* @param[in] contents \ref CapsAlbumFileContents
* @param[in] flags \ref CapsAlbumFileContentsFlag
* @param[out] count Amount of files.
*/
Result capsaGetAlbumFileCountEx0(CapsAlbumStorage storage, CapsAlbumFileContents contents, u64 *count);
Result capsaGetAlbumFileCountEx0(CapsAlbumStorage storage, u8 flags, u64 *count);
/**
* @brief Gets a listing of \ref CapsAlbumEntry, where the AlbumFile's storage and type matches the input one.
* @note Only available on [5.0.0+].
* @param[in] storage \ref CapsAlbumStorage
* @param[in] contents \ref CapsAlbumFileContents
* @param[out] count Total output entries.
* @param[in] flags \ref CapsAlbumFileContentsFlag
* @param[out] out Total output entries.
* @param[out] entries Output array of \ref CapsAlbumEntry.
* @param[in] size Reserved size at entries
* @param[in] count Reserved entry count.
*/
Result capsaGetAlbumFileListEx0(CapsAlbumStorage storage, CapsAlbumFileContents contents, u64 *count, CapsAlbumEntry *entries, u64 size);
Result capsaGetAlbumFileListEx0(CapsAlbumStorage storage, u8 flags, u64 *out, CapsAlbumEntry *entries, u64 count);
/**
* @brief Returns the image from the last shown ScreenShot Overlay.

View File

@ -37,11 +37,11 @@ Result capsaGetAlbumFileCount(CapsAlbumStorage storage, u64 *count) {
return serviceDispatchInOut(&g_capsaSrv, 0, inval, *count);
}
Result capsaGetAlbumFileList(CapsAlbumStorage storage, u64 *count, CapsAlbumEntry *entries, u64 size) {
Result capsaGetAlbumFileList(CapsAlbumStorage storage, u64 *out, CapsAlbumEntry *entries, u64 count) {
u8 inval = storage;
return serviceDispatchInOut(&g_capsaSrv, 1, inval, *count,
return serviceDispatchInOut(&g_capsaSrv, 1, inval, *out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { entries, size } },
.buffers = { { entries, count * sizeof(CapsAlbumEntry) } },
);
}
@ -210,30 +210,30 @@ Result capsaGetMinMaxAppletId(bool *success, u64* min, u64* max) {
return rc;
}
Result capsaGetAlbumFileCountEx0(CapsAlbumStorage storage, CapsAlbumFileContents contents, u64 *count) {
Result capsaGetAlbumFileCountEx0(CapsAlbumStorage storage, u8 flags, u64 *count) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
struct {
CapsAlbumStorage storage;
u8 pad_x1[0x7];
CapsAlbumFileContents contents;
u8 pad_x9[0x7];
} in = { storage, {0}, contents, {0} };
u8 storage;
u8 pad_x1[7];
u8 flags;
u8 pad_x9[7];
} in = { storage, {0}, flags, {0} };
return serviceDispatchInOut(&g_capsaSrv, 100, in, *count);
}
Result capsaGetAlbumFileListEx0(CapsAlbumStorage storage, CapsAlbumFileContents contents, u64 *count, CapsAlbumEntry *entries, u64 size) {
Result capsaGetAlbumFileListEx0(CapsAlbumStorage storage, u8 flags, u64 *out, CapsAlbumEntry *entries, u64 count) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
struct {
CapsAlbumStorage storage;
u8 pad_x1[0x7];
CapsAlbumFileContents contents;
u8 pad_x9[0x7];
} in = { storage, {0}, contents, {0} };
return serviceDispatchInOut(&g_capsaSrv, 101, in, *count,
u8 storage;
u8 pad_x1[7];
u8 contents;
u8 pad_x9[7];
} in = { storage, {0}, flags, {0} };
return serviceDispatchInOut(&g_capsaSrv, 101, in, *out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { entries, size } },
.buffers = { { entries, count * sizeof(CapsAlbumEntry) } },
);
}