lr: Imrpoved path handling and adjust ResolveAddOnContentPath order

This commit is contained in:
Adubbz 2019-08-15 20:13:21 +10:00
parent 8278bda54e
commit 6f99b0bf2b
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::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;
R_TRY(ncm::impl::OpenContentMetaDatabase(&content_meta_database, storage_id));
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));
*out.pointer = path;

View file

@ -30,22 +30,19 @@ namespace sts::lr {
}
Path(const char* path) {
strlcpy(this->path, path, MaxPathLen);
strncpy(this->path, path, MaxPathLen-1);
this->EnsureNullTerminated();
}
Path& operator=(const Path& other) {
/* 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();
return *this;
}
void EnsureNullTerminated() {
const size_t len = strnlen(this->path, MaxPathLen);
if (len == MaxPathLen) {
path[MaxPathLen-1] = '\0';
}
path[MaxPathLen-1] = '\0';
}
};