mirror of
https://github.com/encounter/aurora.git
synced 2026-07-09 18:19:33 -07:00
fix cardProbeFile not working properly with empty card directories, rename enum values in CARDFileType (#136)
This commit is contained in:
@@ -16,10 +16,10 @@ extern "C" {
|
||||
|
||||
#if TARGET_PC
|
||||
|
||||
enum CARDFileType {
|
||||
RawImage,
|
||||
GciFolder,
|
||||
};
|
||||
typedef enum {
|
||||
CARD_RAWIMAGE,
|
||||
CARD_GCIFOLDER,
|
||||
} CARDFileType;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -376,30 +376,7 @@ ECardResult CardGciFolder::getError() const { return ECardResult::READY; }
|
||||
ProbeResults CardGciFolder::probeCardFile(std::string_view filename) {
|
||||
if (!std::filesystem::exists(filename) || !std::filesystem::is_directory(filename))
|
||||
return {ECardResult::NOCARD, 0, 0};
|
||||
|
||||
for (const auto& dir : std::filesystem::directory_iterator(filename)) {
|
||||
if (!dir.is_regular_file()) {
|
||||
continue;
|
||||
}
|
||||
auto path = dir.path();
|
||||
|
||||
if (path.extension() != ".gci")
|
||||
continue;
|
||||
|
||||
FileIO file(path.string());
|
||||
|
||||
File fileData;
|
||||
file.fileRead(&fileData, sizeof(File), 0);
|
||||
fileData.swapEndian();
|
||||
|
||||
bool isGameSame = memcmp(fileData.m_game, m_game, std::size(fileData.m_game)) == 0;
|
||||
bool isMakerSame = memcmp(fileData.m_maker, m_maker, std::size(fileData.m_maker)) == 0;
|
||||
|
||||
if (isGameSame && isMakerSame)
|
||||
return {ECardResult::READY, static_cast<uint32_t>(file.fileSize()), BlockSize};
|
||||
}
|
||||
|
||||
return {ECardResult::NOFILE, 0, 0};
|
||||
return {ECardResult::READY, static_cast<uint32_t>(ECardSize::Card2043Mb), BlockSize};
|
||||
}
|
||||
|
||||
} // namespace aurora::card
|
||||
|
||||
@@ -19,13 +19,12 @@ constexpr uint16_t CARD_SECTOR_SIZE = 8192;
|
||||
#define CARD_REGION "USA"
|
||||
|
||||
#define GET_CARD(slot) CardChannels[slot]
|
||||
#define CARD_READY(slot) (SelectedFileType == GciFolder ? true : std::filesystem::exists(CardChannels[slot]->cardFilename()))
|
||||
#define CARD_USE_GCI_FOLDER SelectedFileType == CARD_GCIFOLDER
|
||||
#define CARD_READY(slot) (CARD_USE_GCI_FOLDER ? true : std::filesystem::exists(CardChannels[slot]->cardFilename()))
|
||||
#define CARD_STUB Log.debug("{} is stubbed.", __FUNCTION__);
|
||||
|
||||
#define CARD_USE_GCI_FOLDER SelectedFileType == GciFolder
|
||||
|
||||
bool Initialized = false;
|
||||
CARDFileType SelectedFileType = CARDFileType::GciFolder;
|
||||
CARDFileType SelectedFileType = CARD_GCIFOLDER;
|
||||
bool UseFastMode = false;
|
||||
|
||||
void CopyKabuFileHandleToDolphin(const s32 chan, const aurora::card::FileHandle& handle, CARDFileInfo* fileInfo) {
|
||||
@@ -151,10 +150,10 @@ void CARDInit(const char* game, const char* maker) {
|
||||
|
||||
for (int i = 0; i < CardChannels.size(); ++i) {
|
||||
switch (SelectedFileType) {
|
||||
case RawImage:
|
||||
case CARD_RAWIMAGE:
|
||||
CardChannels[i] = std::make_unique<aurora::card::CardRawFile>();
|
||||
break;
|
||||
case GciFolder:
|
||||
case CARD_GCIFOLDER:
|
||||
CardChannels[i] = std::make_unique<aurora::card::CardGciFolder>();
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user