Skip to content

Commit

Permalink
move from types back to type+attrib
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor403 committed Jan 11, 2025
1 parent 61a2b13 commit 5ffbc41
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions cubeboot/source/flippy_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ int dvd_custom_open(const char *path, uint8_t type, uint8_t flags) {

strncpy(entry.name, path, 256);
entry.name[255] = 0;
entry.types = type;
entry.type = type;
entry.flags = flags;

DCFlushRange(&entry, sizeof(file_entry_t));
Expand Down Expand Up @@ -482,7 +482,7 @@ int dvd_custom_open_flash(const char *path, uint8_t type, uint8_t flags) {

strncpy(entry.name, path, 256);
entry.name[255] = 0;
entry.types = type;
entry.type = type;
entry.flags = flags;

DCFlushRange(&entry, sizeof(file_entry_t));
Expand Down
27 changes: 14 additions & 13 deletions cubeboot/source/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,32 @@ enum {
};

enum {
FILE_TYPE_FLAG_FILE = 0x00,
FILE_TYPE_FLAG_RDO = 0x01, // AM_RDO
FILE_TYPE_FLAG_HIDDEN = 0x02, // AM_HID
FILE_TYPE_FLAG_SYSTEM = 0x04, // AM_SYS
FILE_TYPE_FLAG_DIR = 0x10, // AM_DIR
FILE_TYPE_FLAG_ARC = 0x20, // AM_ARC
FILE_ENTRY_TYPE_FILE = 0,
FILE_ENTRY_TYPE_DIR = 1,

FILE_ENTRY_TYPE_BAD = 0xFF,
FILE_ENTRY_TYPE_MAX = 0xFF
};

enum {
INTERNAL_FD_TYPE_FILE = 0,
INTERNAL_FD_TYPE_DIR = 1,

INTERNAL_FD_TYPE_BAD = 0xFF,
INTERNAL_FD_TYPE_MAX = 0xFF
FILE_ATTRIB_FLAG_FILE = 0x00,
FILE_ATTRIB_FLAG_RDO = 0x01, // AM_RDO
FILE_ATTRIB_FLAG_HIDDEN = 0x02, // AM_HID
FILE_ATTRIB_FLAG_SYSTEM = 0x04, // AM_SYS
FILE_ATTRIB_FLAG_DIR = 0x10, // AM_DIR
FILE_ATTRIB_FLAG_ARC = 0x20, // AM_ARC
};

typedef struct {
char name[MAX_FILE_NAME];
uint8_t types;
uint8_t type;
uint8_t flags;
uint64_t size;
uint32_t date;
uint32_t time;
uint32_t last_status;
uint8_t pad[10];
uint8_t attrib;
uint8_t pad[9];
} file_entry_t;

ASSERT_SIZE_MULTIPLE_OF_32(file_entry_t);
Expand Down
4 changes: 2 additions & 2 deletions cubeboot/source/sram.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void create_swiss_config() {
dvd_custom_mkdir("/swiss/settings");

// check swiss global config
dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU);
dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU);

GCN_ALIGNED(file_status_t) status;
int ret = dvd_custom_status(&status);
Expand All @@ -46,7 +46,7 @@ void create_swiss_config() {
}

// create swiss global config
ret = dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU | IPC_FILE_FLAG_WRITE);
ret = dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU | IPC_FILE_FLAG_WRITE);
if (ret != 0) return;

// TODO: what do we put in this file?
Expand Down
2 changes: 1 addition & 1 deletion cubeboot/source/uff.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ FRESULT uf_open(const char* path) {
}

__file_offset = 0;
int ret = dvd_custom_open((char*)path, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK);
int ret = dvd_custom_open((char*)path, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK);
iprintf("dvd_custom_open ret: %08x\n", ret);
if (ret != 0) return FR_NOT_OPENED;

Expand Down
10 changes: 5 additions & 5 deletions patches/source/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

void load_stub() {
custom_OSReport("Loading stub...\n");
dvd_custom_open_flash("/stub.bin", FILE_TYPE_FLAG_FILE, 0);
dvd_custom_open_flash("/stub.bin", FILE_ENTRY_TYPE_FILE, 0);
file_status_t *file_status = dvd_custom_status();
if (file_status == NULL || file_status->result != 0) {
custom_OSReport("Failed to open stub\n");
Expand All @@ -38,9 +38,9 @@ __attribute__((aligned(32))) static DOLHEADER dol_hdr;
dol_info_t load_dol(char *path, bool flash) {
uint8_t flags = IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK | IPC_FILE_FLAG_DISABLESPEEDEMU;
if (flash) {
dvd_custom_open_flash(path, FILE_TYPE_FLAG_FILE, flags);
dvd_custom_open_flash(path, FILE_ENTRY_TYPE_FILE, flags);
} else {
dvd_custom_open(path, FILE_TYPE_FLAG_FILE, flags);
dvd_custom_open(path, FILE_ENTRY_TYPE_FILE, flags);
}

file_status_t *file_status = dvd_custom_status();
Expand Down Expand Up @@ -157,7 +157,7 @@ void legacy_chainload_boot_game(gm_file_entry_t *boot_entry, bool passthrough) {

if (!passthrough) {
// open file
dvd_custom_open(boot_entry->path, FILE_TYPE_FLAG_FILE, 0);
dvd_custom_open(boot_entry->path, FILE_ENTRY_TYPE_FILE, 0);
file_status_t *file_status = dvd_custom_status();
if (file_status == NULL || file_status->result != 0) {
custom_OSReport("Failed to open file %s\n", boot_entry->path);
Expand All @@ -169,7 +169,7 @@ void legacy_chainload_boot_game(gm_file_entry_t *boot_entry, bool passthrough) {
custom_OSReport("Boot entry: %s\n", boot_entry->path);
if (boot_entry->second != NULL) {
custom_OSReport("Second entry: %s (valid: %d, %p)\n", boot_entry->second->path, boot_entry->second->second == boot_entry, boot_entry->second);
dvd_custom_open(boot_entry->second->path, FILE_TYPE_FLAG_FILE, 0);
dvd_custom_open(boot_entry->second->path, FILE_ENTRY_TYPE_FILE, 0);
file_status_t *file_status = dvd_custom_status();
if (file_status == NULL || file_status->result != 0) {
custom_OSReport("Failed to open file %s\n", boot_entry->second->path);
Expand Down
2 changes: 1 addition & 1 deletion patches/source/dolphin_dvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ dolphin_game_into_t get_game_info(char *game_path) {
__attribute__((aligned(32))) static u32 small_buf[8]; // for BNR reads

const uint8_t flags = IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLESPEEDEMU;
int ret = dvd_custom_open(game_path, FILE_TYPE_FLAG_FILE, flags);
int ret = dvd_custom_open(game_path, FILE_ENTRY_TYPE_FILE, flags);
if (ret != 0) {
OSReport("ERROR: Failed to open %s\n", game_path);
return (dolphin_game_into_t) { .valid = false };
Expand Down
4 changes: 2 additions & 2 deletions patches/source/flippy_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ int dvd_custom_open(const char *path, uint8_t type, uint8_t flags) {

strncpy(entry.name, path, 256);
entry.name[255] = 0;
entry.types = type;
entry.type = type;
entry.flags = flags;

DCFlushRange(&entry, sizeof(file_entry_t));
Expand Down Expand Up @@ -296,7 +296,7 @@ int dvd_custom_open_flash(const char *path, uint8_t type, uint8_t flags) {

strncpy(entry.name, path, 256);
entry.name[255] = 0;
entry.types = type;
entry.type = type;
entry.flags = flags;

DCFlushRange(&entry, sizeof(file_entry_t));
Expand Down
14 changes: 7 additions & 7 deletions patches/source/games.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ gm_list_info gm_list_files(const char *target_dir) {
OSReport("Listing files in %s\n", target_dir);
u64 start_time = gettime();

int res = dvd_custom_open(target_dir, FILE_TYPE_FLAG_DIR, 0);
int res = dvd_custom_open(target_dir, FILE_ENTRY_TYPE_DIR, 0);
if (res != 0) {
OSReport("PANIC: SD Card could not be opened\n");
while(1);
Expand All @@ -515,12 +515,12 @@ gm_list_info gm_list_files(const char *target_dir) {
int ret = dvd_custom_readdir(&ent, dir_fd);
if (ret != 0) ipl_panic();
if (ent.name[0] == 0) break; // end of directory
if (ent.types & FILE_TYPE_FLAG_HIDDEN) continue; // skip hidden files
if (ent.attrib & FILE_ATTRIB_FLAG_HIDDEN) continue; // skip hidden files
if (check_file_hidden(ent.name)) continue; // skip hidden files

// only check file ext for now
gm_file_type_t file_type = GM_FILE_TYPE_UNKNOWN;
if (ent.types & FILE_TYPE_FLAG_DIR) {
if (ent.type == FILE_ENTRY_TYPE_DIR) {
file_type = GM_FILE_TYPE_DIRECTORY;
} else {
file_type = gm_get_file_type(ent.name);
Expand All @@ -530,15 +530,15 @@ gm_list_info gm_list_files(const char *target_dir) {

#ifdef PRINT_READDIR_NAMES
// logging
OSReport("READDIR ent(%u): %s [len=%d]\n", ent.types, ent.name, strlen(ent.name));
OSReport("READDIR ent(%u): %s [len=%d]\n", ent.type, ent.name, strlen(ent.name));
#endif

// combine the path
strcpy(file_full_path_buf, target_dir);
strcat(file_full_path_buf, ent.name);
#ifdef PRINT_READDIR_NAMES
// logging
OSReport("PATH ent(%u): %s\n", ent.types, file_full_path_buf);
OSReport("PATH ent(%u): %s\n", ent.type, file_full_path_buf);
#endif

// store the path
Expand Down Expand Up @@ -579,7 +579,7 @@ static int gm_load_banner(gm_file_entry_t *entry, u32 aram_offset, bool force_un
if (entry->extra.dvd_bnr_offset == 0) return false;

// load the banner
dvd_custom_open(entry->path, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLESPEEDEMU);
dvd_custom_open(entry->path, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLESPEEDEMU);
file_status_t *status = dvd_custom_status();
if (status == NULL || status->result != 0) {
OSReport("ERROR: could not open file\n");
Expand Down Expand Up @@ -622,7 +622,7 @@ static bool gm_load_icon(gm_file_entry_t *entry, u32 aram_offset, bool force_unl
strcpy(ext, ".png");

// load the icon
dvd_custom_open(icon_path, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK);
dvd_custom_open(icon_path, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK);
file_status_t *status = dvd_custom_status();
if (status == NULL || status->result != 0) {
// OSReport("ERROR: could not open icon file\n");
Expand Down

0 comments on commit 5ffbc41

Please sign in to comment.