Cleanup virtual.c source code

This commit is contained in:
d0k3 2016-12-21 00:31:21 +01:00
parent 0e55882468
commit 0fffa3d2ce
4 changed files with 4 additions and 8 deletions

View File

@ -363,7 +363,6 @@ int ReadNcchImageBytes(u8* buffer, u64 offset, u64 count) {
bool OpenVGameDir(VirtualDir* vdir, VirtualFile* ventry) {
// build vdir object
vdir->index = -1;
vdir->virtual_src = VRT_GAME;
if (!ventry) { // root dir
vdir->offset = 0;
vdir->size = GetMountSize();

View File

@ -34,7 +34,7 @@ bool CheckVirtualDrive(const char* path) {
}
bool ReadVirtualDir(VirtualFile* vfile, VirtualDir* vdir) {
u32 virtual_src = vdir->virtual_src;
u32 virtual_src = vdir->flags & VRT_SOURCE;
bool ret = false;
if (virtual_src & (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND|VRT_XORPAD)) {
ret = ReadVNandDir(vfile, vdir);
@ -57,7 +57,6 @@ bool OpenVirtualRoot(VirtualDir* vdir, u32 virtual_src) {
}
vdir->index = -1;
vdir->flags |= VFLAG_DIR|virtual_src;
vdir->virtual_src = virtual_src;
return true;
}
@ -74,7 +73,6 @@ bool OpenVirtualDir(VirtualDir* vdir, VirtualFile* ventry) {
vdir->flags = ventry->flags;
}
vdir->flags |= virtual_src;
vdir->virtual_src = virtual_src;
return true;
}
@ -96,7 +94,7 @@ bool GetVirtualFile(VirtualFile* vfile, const char* path) {
char* name;
VirtualDir vdir;
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
while (true) {
if (!ReadVirtualDir(vfile, &vdir)) return false;
@ -109,7 +107,7 @@ bool GetVirtualFile(VirtualFile* vfile, const char* path) {
return false;
}
if (!OpenVirtualDir(&vdir, vfile))
vdir.virtual_src = 0;
vdir.flags = 0;
}
return (name == NULL); // if name is NULL, this succeeded

View File

@ -40,7 +40,6 @@ typedef struct {
u64 offset;
u64 size;
u32 flags;
u32 virtual_src;
} __attribute__((packed)) VirtualDir;
u32 GetVirtualSource(const char* path);

View File

@ -37,7 +37,7 @@ bool CheckVNandDrive(u32 nand_src) {
bool ReadVNandDir(VirtualFile* vfile, VirtualDir* vdir) { // uses a generic vdir object generated in virtual.c
int n_templates = sizeof(vNandFileTemplates) / sizeof(VirtualFile);
const VirtualFile* templates = vNandFileTemplates;
u32 nand_src = vdir->virtual_src;
u32 nand_src = vdir->flags & VRT_SOURCE;
while (++vdir->index < n_templates) {
// get NAND type (O3DS/N3DS/NO3DS), workaround for empty EmuNAND