no erpt reports

Block creation for erpt reports
This commit is contained in:
CostelaCNX 2025-02-10 22:06:30 -03:00
parent 1b9d102d45
commit 36a1dd2123
2 changed files with 37 additions and 38 deletions

View File

@ -1,17 +1,17 @@
/*
* Copyright (c) Atmosphère-NX
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "erpt_srv_report_impl.hpp"
@ -20,28 +20,22 @@
namespace ams::erpt::srv {
ReportFileName Report::FileName(ReportId report_id, bool redirect_to_sd) {
AMS_UNUSED(report_id); // Marks the parameter as unused
AMS_UNUSED(redirect_to_sd); // Marks the parameter as unused
ReportFileName report_name;
util::SNPrintf(report_name.name, sizeof(report_name.name),
"%s:/%08x-%04x-%04x-%02x%02x-%04x%08x",
(redirect_to_sd ? ReportOnSdStoragePath : ReportStoragePath),
report_id.uuid_data.time_low,
report_id.uuid_data.time_mid,
report_id.uuid_data.time_high_and_version,
report_id.uuid_data.clock_high,
report_id.uuid_data.clock_low,
static_cast<u32>((report_id.uuid_data.node >> BITSIZEOF(u32)) & 0x0000FFFF),
static_cast<u32>((report_id.uuid_data.node >> 0) & 0xFFFFFFFF));
util::SNPrintf(report_name.name, sizeof(report_name.name), "erpt_disabled");
return report_name;
}
Report::Report(JournalRecord<ReportInfo> *r, bool redirect_to_sd) : m_record(r), m_redirect_to_sd_card(redirect_to_sd) {
Report::Report(JournalRecord<ReportInfo> *r, bool redirect_to_sd)
: m_record(r), m_redirect_to_sd_card(redirect_to_sd) {
m_record->AddReference();
}
Report::~Report() {
this->CloseStream();
if (m_record->RemoveReference()) {
this->DeleteStream(this->FileName().name);
delete m_record;
}
}
@ -51,23 +45,22 @@ namespace ams::erpt::srv {
}
Result Report::Open(ReportOpenType type) {
switch (type) {
case ReportOpenType_Create: R_RETURN(this->OpenStream(this->FileName().name, StreamMode_Write, ReportStreamBufferSize));
case ReportOpenType_Read: R_RETURN(this->OpenStream(this->FileName().name, StreamMode_Read, ReportStreamBufferSize));
default: R_THROW(erpt::ResultInvalidArgument());
}
AMS_UNUSED(type); // Marks the parameter as unused
R_SUCCEED();
}
Result Report::Read(u32 *out_read_count, u8 *dst, u32 dst_size) {
R_RETURN(this->ReadStream(out_read_count, dst, dst_size));
AMS_UNUSED(out_read_count);
AMS_UNUSED(dst);
AMS_UNUSED(dst_size);
R_SUCCEED();
}
Result Report::Delete() {
R_RETURN(this->DeleteStream(this->FileName().name));
R_SUCCEED();
}
void Report::Close() {
return this->CloseStream();
}
Result Report::GetFlags(ReportFlagSet *out) const {
@ -76,15 +69,17 @@ namespace ams::erpt::srv {
}
Result Report::SetFlags(ReportFlagSet flags) {
if (((~m_record->m_info.flags) & flags).IsAnySet()) {
m_record->m_info.flags |= flags;
R_RETURN(Journal::Commit());
}
AMS_UNUSED(flags);
R_SUCCEED();
}
Result Report::GetSize(s64 *out) const {
R_RETURN(this->GetStreamSize(out));
*out = 0;
R_SUCCEED();
}
}
void Report::CloseStream() {
// Implement the logic to close the stream, if necessary
}
}

View File

@ -5,13 +5,13 @@
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
@ -34,10 +34,11 @@ namespace ams::erpt::srv {
bool m_redirect_to_sd_card;
private:
ReportFileName FileName() const;
void CloseStream();
public:
static ReportFileName FileName(ReportId report_id, bool redirect_to_sd);
static ReportFileName FileName(ReportId report_id, bool redirect_to_sd = false);
public:
explicit Report(JournalRecord<ReportInfo> *r, bool redirect_to_sd);
explicit Report(JournalRecord<ReportInfo> *r, bool redirect_to_sd = false);
~Report();
Result Open(ReportOpenType type);
@ -51,13 +52,16 @@ namespace ams::erpt::srv {
template<typename T>
Result Write(T val) {
R_RETURN(this->WriteStream(reinterpret_cast<const u8 *>(std::addressof(val)), sizeof(val)));
(void)val;
R_SUCCEED();
}
template<typename T>
Result Write(const T *buf, u32 buffer_size) {
R_RETURN(this->WriteStream(reinterpret_cast<const u8 *>(buf), buffer_size));
(void)buf;
(void)buffer_size;
R_SUCCEED();
}
};
}
}