JKSV/include/fs/SaveMetaData.hpp
2025-09-04 15:34:43 -04:00

43 lines
1.4 KiB
C++

#pragma once
#include "data/TitleInfo.hpp"
#include <cstdint>
#include <switch.h>
namespace fs
{
/// @brief This is the magic value written to the beginning.
constexpr uint32_t SAVE_META_MAGIC = 0x56534B4A;
/// @brief This is the filename used for the save data meta info.
static constexpr std::string_view NAME_SAVE_META = ".nx_save_meta.bin";
// clang-format off
struct SaveMetaData
{
uint32_t magic{};
uint8_t revision{};
uint64_t applicationID{};
AccountUid accountID{};
uint64_t systemSaveID{};
uint8_t saveDataType{};
uint8_t saveDataRank{};
uint16_t saveDataIndex{};
uint64_t ownerID{};
uint64_t timestamp{};
uint32_t flags{};
int64_t saveDataSize{};
int64_t journalSize{};
uint64_t commitID{};
} __attribute__((packed));
// clang-format on
/// @brief Didn't feel like a whole new file just for this. Fills an fs::SaveMetaData struct.
bool fill_save_meta_data(const FsSaveDataInfo *saveInfo, SaveMetaData &meta) noexcept;
/// @brief Processes the save meta data and applies it to the passed saveInfo pointer.
/// @param saveInfo FsSaveDataInfo to apply the meta to.
/// @param meta Save meta data to apply.
bool process_save_meta_data(const FsSaveDataInfo *saveInfo, const SaveMetaData &meta) noexcept;
} // namespace fs