mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Cleanup virtual.c source code
This commit is contained in:
parent
0e55882468
commit
0fffa3d2ce
@ -363,7 +363,6 @@ int ReadNcchImageBytes(u8* buffer, u64 offset, u64 count) {
|
|||||||
bool OpenVGameDir(VirtualDir* vdir, VirtualFile* ventry) {
|
bool OpenVGameDir(VirtualDir* vdir, VirtualFile* ventry) {
|
||||||
// build vdir object
|
// build vdir object
|
||||||
vdir->index = -1;
|
vdir->index = -1;
|
||||||
vdir->virtual_src = VRT_GAME;
|
|
||||||
if (!ventry) { // root dir
|
if (!ventry) { // root dir
|
||||||
vdir->offset = 0;
|
vdir->offset = 0;
|
||||||
vdir->size = GetMountSize();
|
vdir->size = GetMountSize();
|
||||||
|
@ -34,7 +34,7 @@ bool CheckVirtualDrive(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ReadVirtualDir(VirtualFile* vfile, VirtualDir* vdir) {
|
bool ReadVirtualDir(VirtualFile* vfile, VirtualDir* vdir) {
|
||||||
u32 virtual_src = vdir->virtual_src;
|
u32 virtual_src = vdir->flags & VRT_SOURCE;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (virtual_src & (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND|VRT_XORPAD)) {
|
if (virtual_src & (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND|VRT_XORPAD)) {
|
||||||
ret = ReadVNandDir(vfile, vdir);
|
ret = ReadVNandDir(vfile, vdir);
|
||||||
@ -57,7 +57,6 @@ bool OpenVirtualRoot(VirtualDir* vdir, u32 virtual_src) {
|
|||||||
}
|
}
|
||||||
vdir->index = -1;
|
vdir->index = -1;
|
||||||
vdir->flags |= VFLAG_DIR|virtual_src;
|
vdir->flags |= VFLAG_DIR|virtual_src;
|
||||||
vdir->virtual_src = virtual_src;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +73,6 @@ bool OpenVirtualDir(VirtualDir* vdir, VirtualFile* ventry) {
|
|||||||
vdir->flags = ventry->flags;
|
vdir->flags = ventry->flags;
|
||||||
}
|
}
|
||||||
vdir->flags |= virtual_src;
|
vdir->flags |= virtual_src;
|
||||||
vdir->virtual_src = virtual_src;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +94,7 @@ bool GetVirtualFile(VirtualFile* vfile, const char* path) {
|
|||||||
char* name;
|
char* name;
|
||||||
VirtualDir vdir;
|
VirtualDir vdir;
|
||||||
if (!OpenVirtualRoot(&vdir, virtual_src)) return false;
|
if (!OpenVirtualRoot(&vdir, virtual_src)) return false;
|
||||||
for (name = strtok(lpath + 3, "/"); name && vdir.virtual_src; name = strtok(NULL, "/")) {
|
for (name = strtok(lpath + 3, "/"); name && vdir.flags; name = strtok(NULL, "/")) {
|
||||||
if (!(vdir.flags & VFLAG_LV3)) { // standard method
|
if (!(vdir.flags & VFLAG_LV3)) { // standard method
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!ReadVirtualDir(vfile, &vdir)) return false;
|
if (!ReadVirtualDir(vfile, &vdir)) return false;
|
||||||
@ -109,7 +107,7 @@ bool GetVirtualFile(VirtualFile* vfile, const char* path) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!OpenVirtualDir(&vdir, vfile))
|
if (!OpenVirtualDir(&vdir, vfile))
|
||||||
vdir.virtual_src = 0;
|
vdir.flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (name == NULL); // if name is NULL, this succeeded
|
return (name == NULL); // if name is NULL, this succeeded
|
||||||
|
@ -40,7 +40,6 @@ typedef struct {
|
|||||||
u64 offset;
|
u64 offset;
|
||||||
u64 size;
|
u64 size;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
u32 virtual_src;
|
|
||||||
} __attribute__((packed)) VirtualDir;
|
} __attribute__((packed)) VirtualDir;
|
||||||
|
|
||||||
u32 GetVirtualSource(const char* path);
|
u32 GetVirtualSource(const char* path);
|
||||||
|
@ -37,7 +37,7 @@ bool CheckVNandDrive(u32 nand_src) {
|
|||||||
bool ReadVNandDir(VirtualFile* vfile, VirtualDir* vdir) { // uses a generic vdir object generated in virtual.c
|
bool ReadVNandDir(VirtualFile* vfile, VirtualDir* vdir) { // uses a generic vdir object generated in virtual.c
|
||||||
int n_templates = sizeof(vNandFileTemplates) / sizeof(VirtualFile);
|
int n_templates = sizeof(vNandFileTemplates) / sizeof(VirtualFile);
|
||||||
const VirtualFile* templates = vNandFileTemplates;
|
const VirtualFile* templates = vNandFileTemplates;
|
||||||
u32 nand_src = vdir->virtual_src;
|
u32 nand_src = vdir->flags & VRT_SOURCE;
|
||||||
|
|
||||||
while (++vdir->index < n_templates) {
|
while (++vdir->index < n_templates) {
|
||||||
// get NAND type (O3DS/N3DS/NO3DS), workaround for empty EmuNAND
|
// get NAND type (O3DS/N3DS/NO3DS), workaround for empty EmuNAND
|
||||||
|
Loading…
x
Reference in New Issue
Block a user