lr: Imrpoved path handling and adjust ResolveAddOnContentPath order

This commit is contained in:
Adubbz 2019-08-15 20:13:21 +10:00
parent 75ee69c0b5
commit d0da24920b
2 changed files with 9 additions and 11 deletions

View File

@ -28,12 +28,13 @@ namespace sts::lr {
} }
std::shared_ptr<ncm::IContentMetaDatabase> content_meta_database; std::shared_ptr<ncm::IContentMetaDatabase> content_meta_database;
std::shared_ptr<ncm::IContentStorage> content_storage;
R_TRY(ncm::impl::OpenContentMetaDatabase(&content_meta_database, storage_id));
R_TRY(ncm::impl::OpenContentStorage(&content_storage, storage_id));
ncm::ContentId data_content_id; ncm::ContentId data_content_id;
R_TRY(ncm::impl::OpenContentMetaDatabase(&content_meta_database, storage_id));
R_TRY(content_meta_database->GetLatestData(&data_content_id, tid)); R_TRY(content_meta_database->GetLatestData(&data_content_id, tid));
std::shared_ptr<ncm::IContentStorage> content_storage;
R_TRY(ncm::impl::OpenContentStorage(&content_storage, storage_id));
R_ASSERT(content_storage->GetPath(&path, data_content_id)); R_ASSERT(content_storage->GetPath(&path, data_content_id));
*out.pointer = path; *out.pointer = path;

View File

@ -30,23 +30,20 @@ namespace sts::lr {
} }
Path(const char* path) { Path(const char* path) {
strlcpy(this->path, path, MaxPathLen); strncpy(this->path, path, MaxPathLen-1);
this->EnsureNullTerminated();
} }
Path& operator=(const Path& other) { Path& operator=(const Path& other) {
/* N appears to always memcpy paths, so we will too. */ /* N appears to always memcpy paths, so we will too. */
memcpy(this->path, other.path, MaxPathLen); std::memcpy(this->path, other.path, MaxPathLen);
this->EnsureNullTerminated(); this->EnsureNullTerminated();
return *this; return *this;
} }
void EnsureNullTerminated() { void EnsureNullTerminated() {
const size_t len = strnlen(this->path, MaxPathLen);
if (len == MaxPathLen) {
path[MaxPathLen-1] = '\0'; path[MaxPathLen-1] = '\0';
} }
}
}; };
template<class Key, class Value, size_t N> template<class Key, class Value, size_t N>