mirror of
https://github.com/encounter/aurora.git
synced 2025-07-27 23:45:37 +00:00
Anonymous structs have a limitation on GCC when involving non-trivial default constructors, as it's a compiler extension and not actually standard C++ to use anonymous structs. We can give the struct a concrete name, which fixes this issue.
42 lines
985 B
C++
42 lines
985 B
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include "kabufuda/File.hpp"
|
|
|
|
namespace kabufuda {
|
|
class Directory {
|
|
friend class Card;
|
|
#pragma pack(push, 4)
|
|
struct Data {
|
|
std::array<File, MaxFiles> m_files;
|
|
std::array<uint8_t, 0x3a> padding;
|
|
uint16_t m_updateCounter;
|
|
uint16_t m_checksum;
|
|
uint16_t m_checksumInv;
|
|
};
|
|
union {
|
|
Data data;
|
|
std::array<uint8_t, BlockSize> raw;
|
|
};
|
|
#pragma pack(pop)
|
|
|
|
void swapEndian();
|
|
void updateChecksum();
|
|
bool valid() const;
|
|
|
|
public:
|
|
Directory();
|
|
Directory(uint8_t data[BlockSize]);
|
|
~Directory() = default;
|
|
|
|
bool hasFreeFile() const;
|
|
int32_t numFreeFiles() const;
|
|
File* getFirstFreeFile(const char* game, const char* maker, const char* filename);
|
|
File* getFirstNonFreeFile(uint32_t start, const char* game, const char* maker);
|
|
File* getFile(const char* game, const char* maker, const char* filename);
|
|
File* getFile(uint32_t idx);
|
|
int32_t indexForFile(File* f);
|
|
};
|
|
} // namespace kabufuda
|