|
|
@@ -52,6 +52,16 @@ static bool _vdsceDeleteFile(struct VDir* vd, const char* path); |
|
|
static const char* _vdesceName(struct VDirEntry* vde);
|
|
|
static enum VFSType _vdesceType(struct VDirEntry* vde);
|
|
|
|
|
|
+static bool _vdlsceClose(struct VDir* vd);
|
|
|
+static void _vdlsceRewind(struct VDir* vd);
|
|
|
+static struct VDirEntry* _vdlsceListNext(struct VDir* vd);
|
|
|
+static struct VFile* _vdlsceOpenFile(struct VDir* vd, const char* path, int mode);
|
|
|
+static struct VDir* _vdlsceOpenDir(struct VDir* vd, const char* path);
|
|
|
+static bool _vdlsceDeleteFile(struct VDir* vd, const char* path);
|
|
|
+
|
|
|
+static const char* _vdlesceName(struct VDirEntry* vde);
|
|
|
+static enum VFSType _vdlesceType(struct VDirEntry* vde);
|
|
|
+
|
|
|
struct VFile* VFileOpenSce(const char* path, int flags, SceMode mode) {
|
|
|
struct VFileSce* vfsce = malloc(sizeof(struct VFileSce));
|
|
|
if (!vfsce) {
|
|
|
@@ -148,6 +158,10 @@ bool _vfsceSync(struct VFile* vf, const void* buffer, size_t size) { |
|
|
}
|
|
|
|
|
|
struct VDir* VDirOpen(const char* path) {
|
|
|
+ if (!path || !path[0]) {
|
|
|
+ return VDeviceList();
|
|
|
+ }
|
|
|
+
|
|
|
SceUID dir = sceIoDopen(path);
|
|
|
if (dir < 0) {
|
|
|
return 0;
|
|
|
@@ -250,3 +264,96 @@ static enum VFSType _vdesceType(struct VDirEntry* vde) { |
|
|
}
|
|
|
return VFS_FILE;
|
|
|
}
|
|
|
+
|
|
|
+struct VDirEntrySceDevList {
|
|
|
+ struct VDirEntry d;
|
|
|
+ ssize_t index;
|
|
|
+ const char* name;
|
|
|
+};
|
|
|
+
|
|
|
+struct VDirSceDevList {
|
|
|
+ struct VDir d;
|
|
|
+ struct VDirEntrySceDevList vde;
|
|
|
+};
|
|
|
+
|
|
|
+static const char* _devs[] = {
|
|
|
+ "ux0:",
|
|
|
+ "ur0:",
|
|
|
+ "uma0:"
|
|
|
+};
|
|
|
+
|
|
|
+struct VDir* VDeviceList() {
|
|
|
+ struct VDirSceDevList* vd = malloc(sizeof(struct VDirSceDevList));
|
|
|
+ if (!vd) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ vd->d.close = _vdlsceClose;
|
|
|
+ vd->d.rewind = _vdlsceRewind;
|
|
|
+ vd->d.listNext = _vdlsceListNext;
|
|
|
+ vd->d.openFile = _vdlsceOpenFile;
|
|
|
+ vd->d.openDir = _vdlsceOpenDir;
|
|
|
+ vd->d.deleteFile = _vdlsceDeleteFile;
|
|
|
+
|
|
|
+ vd->vde.d.name = _vdlesceName;
|
|
|
+ vd->vde.d.type = _vdlesceType;
|
|
|
+ vd->vde.index = -1;
|
|
|
+ vd->vde.name = 0;
|
|
|
+
|
|
|
+ return &vd->d;
|
|
|
+}
|
|
|
+
|
|
|
+static bool _vdlsceClose(struct VDir* vd) {
|
|
|
+ struct VDirSceDevList* vdl = (struct VDirSceDevList*) vd;
|
|
|
+ free(vdl);
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+static void _vdlsceRewind(struct VDir* vd) {
|
|
|
+ struct VDirSceDevList* vdl = (struct VDirSceDevList*) vd;
|
|
|
+ vdl->vde.name = NULL;
|
|
|
+ vdl->vde.index = -1;
|
|
|
+}
|
|
|
+
|
|
|
+static struct VDirEntry* _vdlsceListNext(struct VDir* vd) {
|
|
|
+ struct VDirSceDevList* vdl = (struct VDirSceDevList*) vd;
|
|
|
+ while (vdl->vde.index < 3) {
|
|
|
+ ++vdl->vde.index;
|
|
|
+ vdl->vde.name = _devs[vdl->vde.index];
|
|
|
+ SceUID dir = sceIoDopen(vdl->vde.name);
|
|
|
+ if (dir < 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ sceIoDclose(dir);
|
|
|
+ return &vdl->vde.d;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static struct VFile* _vdlsceOpenFile(struct VDir* vd, const char* path, int mode) {
|
|
|
+ UNUSED(vd);
|
|
|
+ UNUSED(path);
|
|
|
+ UNUSED(mode);
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+static struct VDir* _vdlsceOpenDir(struct VDir* vd, const char* path) {
|
|
|
+ UNUSED(vd);
|
|
|
+ return VDirOpen(path);
|
|
|
+}
|
|
|
+
|
|
|
+static bool _vdlsceDeleteFile(struct VDir* vd, const char* path) {
|
|
|
+ UNUSED(vd);
|
|
|
+ UNUSED(path);
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+static const char* _vdlesceName(struct VDirEntry* vde) {
|
|
|
+ struct VDirEntrySceDevList* vdle = (struct VDirEntrySceDevList*) vde;
|
|
|
+ return vdle->name;
|
|
|
+}
|
|
|
+
|
|
|
+static enum VFSType _vdlesceType(struct VDirEntry* vde) {
|
|
|
+ UNUSED(vde);
|
|
|
+ return VFS_DIRECTORY;
|
|
|
+}
|
0 comments on commit
3a9d77d