diff --git a/src/platform/3ds/3ds-vfs.c b/src/platform/3ds/3ds-vfs.c index b7a8075d8..101a5a49c 100644 --- a/src/platform/3ds/3ds-vfs.c +++ b/src/platform/3ds/3ds-vfs.c @@ -44,6 +44,7 @@ static bool _vd3dClose(struct VDir* vd); static void _vd3dRewind(struct VDir* vd); static struct VDirEntry* _vd3dListNext(struct VDir* vd); static struct VFile* _vd3dOpenFile(struct VDir* vd, const char* path, int mode); +static struct VDir* _vd3dOpenDir(struct VDir* vd, const char* path); static const char* _vd3deName(struct VDirEntry* vde); static enum VFSType _vd3deType(struct VDirEntry* vde); @@ -185,8 +186,9 @@ struct VDir* VDirOpen(const char* path) { vd3d->d.close = _vd3dClose; vd3d->d.rewind = _vd3dRewind; - vd3d->d.listNext = _vd3dListNext; //// Crashes here for no good reason + vd3d->d.listNext = _vd3dListNext; vd3d->d.openFile = _vd3dOpenFile; + vd3d->d.openDir = _vd3dOpenDir; vd3d->vde.d.name = _vd3deName; vd3d->vde.d.type = _vd3deType; @@ -235,6 +237,23 @@ static struct VFile* _vd3dOpenFile(struct VDir* vd, const char* path, int mode) return file; } +static struct VDir* _vd3dOpenDir(struct VDir* vd, const char* path) { + struct VDir3DS* vd3d = (struct VDir3DS*) vd; + if (!path) { + return 0; + } + const char* dir = vd3d->path; + char* combined = malloc(sizeof(char) * (strlen(path) + strlen(dir) + 2)); + sprintf(combined, "%s/%s", dir, path); + + struct VDir* vd2 = VDirOpen(combined); + if (!vd2) { + vd2 = VDirOpenArchive(combined); + } + free(combined); + return vd2; +} + static const char* _vd3deName(struct VDirEntry* vde) { struct VDirEntry3DS* vd3de = (struct VDirEntry3DS*) vde; if (!vd3de->utf8Name[0]) { diff --git a/src/platform/psp2/sce-vfs.c b/src/platform/psp2/sce-vfs.c index a694763cf..e949e0056 100644 --- a/src/platform/psp2/sce-vfs.c +++ b/src/platform/psp2/sce-vfs.c @@ -42,6 +42,7 @@ static bool _vdsceClose(struct VDir* vd); static void _vdsceRewind(struct VDir* vd); static struct VDirEntry* _vdsceListNext(struct VDir* vd); static struct VFile* _vdsceOpenFile(struct VDir* vd, const char* path, int mode); +static struct VDir* _vdsceOpenDir(struct VDir* vd, const char* path); static const char* _vdesceName(struct VDirEntry* vde); static enum VFSType _vdesceType(struct VDirEntry* vde); @@ -150,6 +151,7 @@ struct VDir* VDirOpen(const char* path) { vd->d.rewind = _vdsceRewind; vd->d.listNext = _vdsceListNext; vd->d.openFile = _vdsceOpenFile; + vd->d.openDir = _vdsceOpenDir; vd->path = strdup(path); vd->de.d.name = _vdesceName; @@ -190,13 +192,29 @@ struct VFile* _vdsceOpenFile(struct VDir* vd, const char* path, int mode) { const char* dir = vdsce->path; char* combined = malloc(sizeof(char) * (strlen(path) + strlen(dir) + strlen(PATH_SEP) + 1)); sprintf(combined, "%s%s%s", dir, PATH_SEP, path); - printf("Opening %s\n", combined); struct VFile* file = VFileOpen(combined, mode); free(combined); return file; } +struct VDir* _vdsceOpenDir(struct VDir* vd, const char* path) { + struct VDirSce* vdsce = (struct VDirSce*) vd; + if (!path) { + return 0; + } + const char* dir = vdsce->path; + char* combined = malloc(sizeof(char) * (strlen(path) + strlen(dir) + strlen(PATH_SEP) + 1)); + sprintf(combined, "%s%s%s", dir, PATH_SEP, path); + + struct VDir* vd2 = VDirOpen(combined); + if (!vd2) { + vd2 = VDirOpenArchive(combined); + } + free(combined); + return vd2; +} + static const char* _vdesceName(struct VDirEntry* vde) { struct VDirEntrySce* vdesce = (struct VDirEntrySce*) vde; return vdesce->ent.d_name; diff --git a/src/util/vfs.h b/src/util/vfs.h index 4763aefa5..f08322654 100644 --- a/src/util/vfs.h +++ b/src/util/vfs.h @@ -58,6 +58,7 @@ struct VDir { void (*rewind)(struct VDir* vd); struct VDirEntry* (*listNext)(struct VDir* vd); struct VFile* (*openFile)(struct VDir* vd, const char* name, int mode); + struct VDir* (*openDir)(struct VDir* vd, const char* name); }; struct VFile* VFileOpen(const char* path, int flags); diff --git a/src/util/vfs/vfs-dirent.c b/src/util/vfs/vfs-dirent.c index 0d53c3f52..c3ce64321 100644 --- a/src/util/vfs/vfs-dirent.c +++ b/src/util/vfs/vfs-dirent.c @@ -14,6 +14,7 @@ static bool _vdClose(struct VDir* vd); static void _vdRewind(struct VDir* vd); static struct VDirEntry* _vdListNext(struct VDir* vd); static struct VFile* _vdOpenFile(struct VDir* vd, const char* path, int mode); +static struct VDir* _vdOpenDir(struct VDir* vd, const char* path); static const char* _vdeName(struct VDirEntry* vde); static enum VFSType _vdeType(struct VDirEntry* vde); @@ -48,6 +49,7 @@ struct VDir* VDirOpen(const char* path) { vd->d.rewind = _vdRewind; vd->d.listNext = _vdListNext; vd->d.openFile = _vdOpenFile; + vd->d.openDir = _vdOpenDir; vd->path = strdup(path); vd->de = de; @@ -97,6 +99,23 @@ struct VFile* _vdOpenFile(struct VDir* vd, const char* path, int mode) { return file; } +struct VDir* _vdOpenDir(struct VDir* vd, const char* path) { + struct VDirDE* vdde = (struct VDirDE*) vd; + if (!path) { + return 0; + } + const char* dir = vdde->path; + char* combined = malloc(sizeof(char) * (strlen(path) + strlen(dir) + 2)); + sprintf(combined, "%s%s%s", dir, PATH_SEP, path); + + struct VDir* vd2 = VDirOpen(combined); + if (!vd2) { + vd2 = VDirOpenArchive(combined); + } + free(combined); + return vd2; +} + const char* _vdeName(struct VDirEntry* vde) { struct VDirEntryDE* vdede = (struct VDirEntryDE*) vde; if (vdede->ent) { diff --git a/src/util/vfs/vfs-lzma.c b/src/util/vfs/vfs-lzma.c index 97b711deb..6867ec456 100644 --- a/src/util/vfs/vfs-lzma.c +++ b/src/util/vfs/vfs-lzma.c @@ -62,6 +62,7 @@ static bool _vd7zClose(struct VDir* vd); static void _vd7zRewind(struct VDir* vd); static struct VDirEntry* _vd7zListNext(struct VDir* vd); static struct VFile* _vd7zOpenFile(struct VDir* vd, const char* path, int mode); +static struct VDir* _vd7zOpenDir(struct VDir* vd, const char* path); static const char* _vde7zName(struct VDirEntry* vde); static enum VFSType _vde7zType(struct VDirEntry* vde); @@ -111,6 +112,7 @@ struct VDir* VDirOpen7z(const char* path, int flags) { vd->d.rewind = _vd7zRewind; vd->d.listNext = _vd7zListNext; vd->d.openFile = _vd7zOpenFile; + vd->d.openDir = _vd7zOpenDir; return &vd->d; } @@ -301,6 +303,12 @@ struct VFile* _vd7zOpenFile(struct VDir* vd, const char* path, int mode) { return &vf->d; } +struct VDir* _vd7zOpenDir(struct VDir* vd, const char* path) { + UNUSED(vd); + UNUSED(path); + return 0; +} + bool _vf7zSync(struct VFile* vf, const void* memory, size_t size) { UNUSED(vf); UNUSED(memory); diff --git a/src/util/vfs/vfs-zip.c b/src/util/vfs/vfs-zip.c index 314085302..3c37b125a 100644 --- a/src/util/vfs/vfs-zip.c +++ b/src/util/vfs/vfs-zip.c @@ -49,6 +49,7 @@ static bool _vdzClose(struct VDir* vd); static void _vdzRewind(struct VDir* vd); static struct VDirEntry* _vdzListNext(struct VDir* vd); static struct VFile* _vdzOpenFile(struct VDir* vd, const char* path, int mode); +static struct VDir* _vdzOpenDir(struct VDir* vd, const char* path); static const char* _vdezName(struct VDirEntry* vde); static enum VFSType _vdezType(struct VDirEntry* vde); @@ -72,6 +73,7 @@ struct VDir* VDirOpenZip(const char* path, int flags) { vd->d.rewind = _vdzRewind; vd->d.listNext = _vdzListNext; vd->d.openFile = _vdzOpenFile; + vd->d.openDir = _vdzOpenDir; vd->z = z; vd->dirent.d.name = _vdezName; @@ -297,6 +299,12 @@ struct VFile* _vdzOpenFile(struct VDir* vd, const char* path, int mode) { return &vfz->d; } +struct VDir* _vdzOpenDir(struct VDir* vd, const char* path) { + UNUSED(vd); + UNUSED(path); + return 0; +} + bool _vfzSync(struct VFile* vf, const void* memory, size_t size) { UNUSED(vf); UNUSED(memory);