mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-04-22 12:34:47 +00:00
Adopted AMS_ABORT_UNLESS
This commit is contained in:
parent
4014070607
commit
1da366f791
7 changed files with 22 additions and 70 deletions
|
@ -30,9 +30,7 @@ namespace ams::ncm {
|
|||
R_TRY(fs::CheckContentStorageDirectoriesExist(root_path));
|
||||
const size_t root_path_len = strnlen(root_path, FS_MAX_PATH-1);
|
||||
|
||||
if (root_path_len >= FS_MAX_PATH-1) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(root_path_len < FS_MAX_PATH-1);
|
||||
|
||||
strncpy(this->root_path, root_path, FS_MAX_PATH-2);
|
||||
this->make_content_path_func = *content_path_func;
|
||||
|
@ -457,9 +455,8 @@ namespace ams::ncm {
|
|||
|
||||
bool is_development = false;
|
||||
|
||||
if (R_FAILED(splIsDevelopment(&is_development)) || !is_development) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(R_SUCCEEDED(splIsDevelopment(&is_development)));
|
||||
AMS_ABORT_UNLESS(is_development);
|
||||
|
||||
this->ClearContentCache();
|
||||
|
||||
|
|
|
@ -221,10 +221,7 @@ namespace ams::ncm::fs {
|
|||
|
||||
FsFileSystem fs;
|
||||
R_TRY(fsOpenSaveDataFileSystemBySystemSaveDataId(&fs, space_id, &save));
|
||||
|
||||
if (fsdevMountDevice(mount_point, fs) == -1) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(fsdevMountDevice(mount_point, fs) != -1);
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -244,10 +241,7 @@ namespace ams::ncm::fs {
|
|||
|
||||
FsFileSystem fs;
|
||||
R_TRY(fsOpenContentStorageFileSystem(&fs, id));
|
||||
|
||||
if (fsdevMountDevice(mount_point, fs) == -1) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(fsdevMountDevice(mount_point, fs) != -1);
|
||||
|
||||
switch (id) {
|
||||
case FsContentStorageId_System:
|
||||
|
@ -269,16 +263,11 @@ namespace ams::ncm::fs {
|
|||
}
|
||||
|
||||
Result MountGameCardPartition(const char* mount_point, const FsGameCardHandle handle, FsGameCardPartition partition) {
|
||||
if (partition > 2) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(partition <= 2);
|
||||
|
||||
FsFileSystem fs;
|
||||
R_TRY(fsOpenGameCardFileSystem(&fs, &handle, partition));
|
||||
|
||||
if (fsdevMountDevice(mount_point, fs) == -1) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(fsdevMountDevice(mount_point, fs) != -1);
|
||||
|
||||
MountName mount = {0};
|
||||
snprintf(mount.name, sizeof(MountName), "%s%s%08x", GameCardMountNameBase, GameCardPartitionLetters[partition], handle.value);
|
||||
|
@ -288,14 +277,9 @@ namespace ams::ncm::fs {
|
|||
|
||||
Result Unmount(const char* mount_point) {
|
||||
R_UNLESS(mount_point, ams::fs::ResultNullptrArgument());
|
||||
|
||||
/* Erase any content storage mappings which may potentially exist. */
|
||||
g_mount_content_storage.erase(mount_point);
|
||||
|
||||
if (fsdevUnmountDevice(mount_point) == -1) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
AMS_ABORT_UNLESS(fsdevUnmountDevice(mount_point) != -1);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
|
@ -311,10 +295,7 @@ namespace ams::ncm::fs {
|
|||
char translated_path[FS_MAX_PATH] = {0};
|
||||
std::string common_mount_name = g_mount_content_storage[mount_name.name];
|
||||
|
||||
if (fsdevTranslatePath(path, NULL, translated_path) == -1) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
AMS_ABORT_UNLESS(fsdevTranslatePath(path, NULL, translated_path) != -1);
|
||||
snprintf(out_common_path, out_len, "%s:%s", common_mount_name.c_str(), translated_path);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
|
|
@ -69,9 +69,7 @@ namespace ams::ncm::fs {
|
|||
}
|
||||
|
||||
char current_path[FS_MAX_PATH];
|
||||
if (snprintf(current_path, FS_MAX_PATH-1, "%s/%s", root_path, dir_entry->d_name) < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(current_path, FS_MAX_PATH-1, "%s/%s", root_path, dir_entry->d_name) >= 0);
|
||||
|
||||
bool should_continue = true;
|
||||
bool should_retry_dir_read = false;
|
||||
|
|
|
@ -38,9 +38,7 @@ namespace ams::ncm::path {
|
|||
void MakeContentPathFlat(char* path_out, ContentId content_id, const char* root) {
|
||||
char content_name[FS_MAX_PATH] = {0};
|
||||
GetContentFileName(content_name, content_id);
|
||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%s", root, content_name) < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%s", root, content_name) >= 0);
|
||||
}
|
||||
|
||||
void MakeContentPathDualLayered(char* path_out, ContentId content_id, const char* root) {
|
||||
|
@ -50,44 +48,34 @@ namespace ams::ncm::path {
|
|||
const u32 hash_upper = (hash >> 10) & 0x3f;
|
||||
|
||||
GetContentFileName(content_name, content_id);
|
||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%08X/%s", root, hash_upper, hash_lower, content_name) < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%08X/%s", root, hash_upper, hash_lower, content_name) >= 0);
|
||||
}
|
||||
|
||||
void MakeContentPath10BitLayered(char* path_out, ContentId content_id, const char* root) {
|
||||
char content_name[FS_MAX_PATH] = {0};
|
||||
const u32 hash = (Get16BitSha256HashPrefix(content_id.uuid) >> 6) & 0x3FF;
|
||||
GetContentFileName(content_name, content_id);
|
||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash, content_name) < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash, content_name) >= 0);
|
||||
}
|
||||
|
||||
void MakeContentPathHashByteLayered(char* path_out, ContentId content_id, const char* root) {
|
||||
char content_name[FS_MAX_PATH] = {0};
|
||||
const u32 hash_byte = static_cast<u32>(Get8BitSha256HashPrefix(content_id.uuid));
|
||||
GetContentFileName(content_name, content_id);
|
||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, content_name) < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, content_name) >= 0);
|
||||
}
|
||||
|
||||
void MakePlaceHolderPathFlat(char* path_out, PlaceHolderId placeholder_id, const char* root) {
|
||||
char placeholder_name[FS_MAX_PATH] = {0};
|
||||
GetPlaceHolderFileName(placeholder_name, placeholder_id);
|
||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%s", root, placeholder_name) < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%s", root, placeholder_name) >= 0);
|
||||
}
|
||||
|
||||
void MakePlaceHolderPathHashByteLayered(char* path_out, PlaceHolderId placeholder_id, const char* root) {
|
||||
char placeholder_name[FS_MAX_PATH] = {0};
|
||||
const u32 hash_byte = static_cast<u32>(Get8BitSha256HashPrefix(placeholder_id.uuid));
|
||||
GetPlaceHolderFileName(placeholder_name, placeholder_id);
|
||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, placeholder_name) < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, placeholder_name) >= 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,18 +26,14 @@ namespace ams::ncm::path {
|
|||
const size_t len = strnlen(content_path, FS_MAX_PATH-1);
|
||||
const size_t len_no_extension = len - 4;
|
||||
|
||||
if (len_no_extension > len || len_no_extension >= FS_MAX_PATH-1) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(len_no_extension <= len);
|
||||
AMS_ABORT_UNLESS(len_no_extension < FS_MAX_PATH-1);
|
||||
|
||||
strncpy(tmp_path, content_path, len_no_extension);
|
||||
memcpy(out, tmp_path, FS_MAX_PATH-1);
|
||||
const size_t out_len = strnlen(out, FS_MAX_PATH-1);
|
||||
|
||||
if (out_len + 9 >= FS_MAX_PATH-1) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
AMS_ABORT_UNLESS(out_len + 9 < FS_MAX_PATH-1);
|
||||
strncat(out, ".cnmt.nca", 0x2ff - out_len);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,16 +22,12 @@ namespace ams::ncm::path {
|
|||
|
||||
inline void GetContentRootPath(char* out_content_root, const char* root_path) {
|
||||
/* TODO: Replace with BoundedString? */
|
||||
if (snprintf(out_content_root, FS_MAX_PATH-1, "%s%s", root_path, "/registered") < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(out_content_root, FS_MAX_PATH-1, "%s%s", root_path, "/registered") >= 0);
|
||||
}
|
||||
|
||||
inline void GetPlaceHolderRootPath(char* out_placeholder_root, const char* root_path) {
|
||||
/* TODO: Replace with BoundedString? */
|
||||
if (snprintf(out_placeholder_root, FS_MAX_PATH, "%s%s", root_path, "/placehld") < 0) {
|
||||
std::abort();
|
||||
}
|
||||
AMS_ABORT_UNLESS(snprintf(out_placeholder_root, FS_MAX_PATH, "%s%s", root_path, "/placehld") >= 0);
|
||||
}
|
||||
|
||||
void GetContentMetaPath(char* out, ContentId content_id, MakeContentPathFunc path_func, const char* root_path);
|
||||
|
|
|
@ -24,11 +24,7 @@ namespace ams::ncm {
|
|||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
const size_t root_path_len = strnlen(root_path, FS_MAX_PATH-1);
|
||||
|
||||
if (root_path_len >= FS_MAX_PATH-1) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
AMS_ABORT_UNLESS(root_path_len < FS_MAX_PATH-1);
|
||||
strncpy(this->root_path, root_path, FS_MAX_PATH-2);
|
||||
this->make_content_path_func = *content_path_func;
|
||||
return ResultSuccess();
|
||||
|
|
Loading…
Add table
Reference in a new issue