#include #include #include #include #include "config.h" #include "title.h" #include "video.h" /* NANDLoader configuration */ struct config loaderCfg ATTRIBUTE_ALIGN(32) = { 0 }; /* Macros */ #define NB_ENTRIES (sizeof(entryList) / sizeof(struct menu)) s32 __Config_GetFilePath(char *outbuf) { static char nandpath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); u64 tid; s32 ret; /* Get title ID */ ret = ES_GetTitleID(&tid); if (ret < 0) return ret; /* Get data directory */ ret = ES_GetDataDir(tid, nandpath); if (ret < 0) return ret; /* Generate filepath */ sprintf(outbuf, "%s/nand.cfg", nandpath); return 0; } s32 Config_Read(void) { char filepath[ISFS_MAXPATH]; s32 fd, ret; /* Get config filepath */ ret = __Config_GetFilePath(filepath); if (ret < 0) return ret; /* Open config file */ fd = IOS_Open(filepath, ISFS_OPEN_READ); if (fd < 0) return fd; /* Read config */ ret = IOS_Read(fd, &loaderCfg, sizeof(loaderCfg)); /* Close config file */ IOS_Close(fd); return ret; } s32 Config_Write(void) { char filepath[ISFS_MAXPATH]; s32 fd, ret; /* Get config filepath */ ret = __Config_GetFilePath(filepath); if (ret < 0) return ret; /* Create config file */ ISFS_CreateFile(filepath, 0, ISFS_OPEN_RW, ISFS_OPEN_READ, ISFS_OPEN_READ); /* Open config file */ fd = IOS_Open(filepath, ISFS_OPEN_WRITE); if (fd < 0) return fd; /* Write config */ ret = IOS_Write(fd, &loaderCfg, sizeof(loaderCfg)); /* Close config file */ IOS_Close(fd); return ret; }