Files
aurora/lib/card/Directory.hpp
CraftyBoss a801671643 Card gci folder update (#135)
* add ability to set path of card image before CARDInit

* begin work on updating card class to support gci folders

a lot of work will just be directly reading from whatever folder is supplied, instead of relying on an always open FileIO handle

* swap to interface system for easier code seperation, begin actually planning out logic for gci loading

* fix wrong name for func, add modified time to new gci file entry

* get gci folder working

tp seems to be happy with everything ive done, the only funcs im worried about are getSerial and getChecksum as those dont do anything atm.

* fix createFile not assigning file index to output FileHandle, CARDSetLoadType now takes an enum

* make probeCardFile a virtual func so GciFolder and RawFile can both implement their own, bit of cleanup
2026-04-23 22:39:42 -07:00

46 lines
1017 B
C++

#pragma once
#include <array>
#include <cstdint>
#include "File.hpp"
namespace aurora::card {
class Directory {
friend class CardRawFile;
#pragma pack(push, 4)
using RawData = std::array<uint8_t, BlockSize>;
struct Data {
File m_files[MaxFiles];
uint8_t padding[0x3a];
uint16_t m_updateCounter;
uint16_t m_checksum;
uint16_t m_checksumInv;
};
#pragma pack(pop)
union {
Data data;
RawData raw;
};
void swapEndian();
void updateChecksum();
bool valid() const;
public:
Directory();
explicit Directory(const RawData& rawData);
~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(const File* f) const;
};
} // namespace aurora::card