mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-06 17:42:14 +02:00
Improved type safety
This commit is contained in:
parent
b17c556fcb
commit
01c7f3242c
@ -518,7 +518,7 @@ namespace sts::ncm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update the cache. */
|
/* Update the cache. */
|
||||||
eviction_candidate->uuid = content_id;
|
eviction_candidate->uuid = content_id.uuid;
|
||||||
eviction_candidate->rights_id = rights_id;
|
eviction_candidate->rights_id = rights_id;
|
||||||
eviction_candidate->key_generation = key_generation;
|
eviction_candidate->key_generation = key_generation;
|
||||||
eviction_candidate->last_accessed = rights_id_cache->counter;
|
eviction_candidate->last_accessed = rights_id_cache->counter;
|
||||||
@ -705,7 +705,7 @@ namespace sts::ncm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update the cache. */
|
/* Update the cache. */
|
||||||
eviction_candidate->uuid = cache_content_id;
|
eviction_candidate->uuid = cache_content_id.uuid;
|
||||||
eviction_candidate->rights_id = rights_id;
|
eviction_candidate->rights_id = rights_id;
|
||||||
eviction_candidate->key_generation = key_generation;
|
eviction_candidate->key_generation = key_generation;
|
||||||
eviction_candidate->last_accessed = rights_id_cache->counter;
|
eviction_candidate->last_accessed = rights_id_cache->counter;
|
||||||
|
@ -45,7 +45,7 @@ namespace sts::ncm::path {
|
|||||||
|
|
||||||
void MakeContentPathDualLayered(char* path_out, ContentId content_id, const char* root) {
|
void MakeContentPathDualLayered(char* path_out, ContentId content_id, const char* root) {
|
||||||
char content_name[FS_MAX_PATH] = {0};
|
char content_name[FS_MAX_PATH] = {0};
|
||||||
const u16 hash = Get16BitSha256HashPrefix(content_id);
|
const u16 hash = Get16BitSha256HashPrefix(content_id.uuid);
|
||||||
const u32 hash_lower = (hash >> 4) & 0x3f;
|
const u32 hash_lower = (hash >> 4) & 0x3f;
|
||||||
const u32 hash_upper = (hash >> 10) & 0x3f;
|
const u32 hash_upper = (hash >> 10) & 0x3f;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ namespace sts::ncm::path {
|
|||||||
|
|
||||||
void MakeContentPath10BitLayered(char* path_out, ContentId content_id, const char* root) {
|
void MakeContentPath10BitLayered(char* path_out, ContentId content_id, const char* root) {
|
||||||
char content_name[FS_MAX_PATH] = {0};
|
char content_name[FS_MAX_PATH] = {0};
|
||||||
const u32 hash = (Get16BitSha256HashPrefix(content_id) >> 6) & 0x3FF;
|
const u32 hash = (Get16BitSha256HashPrefix(content_id.uuid) >> 6) & 0x3FF;
|
||||||
GetContentFileName(content_name, content_id);
|
GetContentFileName(content_name, content_id);
|
||||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash, content_name) < 0) {
|
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash, content_name) < 0) {
|
||||||
std::abort();
|
std::abort();
|
||||||
@ -66,7 +66,7 @@ namespace sts::ncm::path {
|
|||||||
|
|
||||||
void MakeContentPathHashByteLayered(char* path_out, ContentId content_id, const char* root) {
|
void MakeContentPathHashByteLayered(char* path_out, ContentId content_id, const char* root) {
|
||||||
char content_name[FS_MAX_PATH] = {0};
|
char content_name[FS_MAX_PATH] = {0};
|
||||||
const u32 hash_byte = static_cast<u32>(Get8BitSha256HashPrefix(content_id));
|
const u32 hash_byte = static_cast<u32>(Get8BitSha256HashPrefix(content_id.uuid));
|
||||||
GetContentFileName(content_name, content_id);
|
GetContentFileName(content_name, content_id);
|
||||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, content_name) < 0) {
|
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, content_name) < 0) {
|
||||||
std::abort();
|
std::abort();
|
||||||
@ -83,7 +83,7 @@ namespace sts::ncm::path {
|
|||||||
|
|
||||||
void MakePlaceHolderPathHashByteLayered(char* path_out, PlaceHolderId placeholder_id, const char* root) {
|
void MakePlaceHolderPathHashByteLayered(char* path_out, PlaceHolderId placeholder_id, const char* root) {
|
||||||
char placeholder_name[FS_MAX_PATH] = {0};
|
char placeholder_name[FS_MAX_PATH] = {0};
|
||||||
const u32 hash_byte = static_cast<u32>(Get8BitSha256HashPrefix(placeholder_id));
|
const u32 hash_byte = static_cast<u32>(Get8BitSha256HashPrefix(placeholder_id.uuid));
|
||||||
GetPlaceHolderFileName(placeholder_name, placeholder_id);
|
GetPlaceHolderFileName(placeholder_name, placeholder_id);
|
||||||
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, placeholder_name) < 0) {
|
if (snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, placeholder_name) < 0) {
|
||||||
std::abort();
|
std::abort();
|
||||||
|
@ -45,8 +45,12 @@ namespace sts::ncm {
|
|||||||
struct PlaceHolderId {
|
struct PlaceHolderId {
|
||||||
Uuid uuid;
|
Uuid uuid;
|
||||||
|
|
||||||
inline operator Uuid() const {
|
bool operator==(const PlaceHolderId& other) const {
|
||||||
return this->uuid;
|
return this->uuid == other.uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const PlaceHolderId& other) const {
|
||||||
|
return this->uuid != other.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Uuid& other) const {
|
bool operator==(const Uuid& other) const {
|
||||||
@ -63,8 +67,12 @@ namespace sts::ncm {
|
|||||||
struct ContentId {
|
struct ContentId {
|
||||||
Uuid uuid;
|
Uuid uuid;
|
||||||
|
|
||||||
inline operator Uuid() const {
|
bool operator==(const ContentId& other) const {
|
||||||
return this->uuid;
|
return this->uuid == other.uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const ContentId& other) const {
|
||||||
|
return this->uuid != other.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Uuid& other) const {
|
bool operator==(const Uuid& other) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user