mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Added delete code for certain virtual files (not used)
This commit is contained in:
parent
5941ce41bc
commit
c164077434
@ -101,8 +101,12 @@ FRESULT fvx_rename (const TCHAR* path_old, const TCHAR* path_new) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FRESULT fvx_unlink (const TCHAR* path) {
|
FRESULT fvx_unlink (const TCHAR* path) {
|
||||||
if (GetVirtualSource(path)) return FR_DENIED;
|
if (GetVirtualSource(path)) {
|
||||||
return fa_unlink( path );
|
VirtualFile vfile;
|
||||||
|
if (!GetVirtualFile(&vfile, path)) return FR_NO_PATH;
|
||||||
|
if (DeleteVirtualFile(&vfile) != 0) return FR_DENIED;
|
||||||
|
return FR_OK;
|
||||||
|
} else return fa_unlink( path );
|
||||||
}
|
}
|
||||||
|
|
||||||
FRESULT fvx_mkdir (const TCHAR* path) {
|
FRESULT fvx_mkdir (const TCHAR* path) {
|
||||||
@ -237,7 +241,7 @@ FRESULT worker_fvx_runlink (TCHAR* tpath) {
|
|||||||
FRESULT res;
|
FRESULT res;
|
||||||
|
|
||||||
// this code handles directory content deletion
|
// this code handles directory content deletion
|
||||||
if ((res = fa_stat(tpath, &fno)) != FR_OK) return res; // tpath does not exist
|
if ((res = fvx_stat(tpath, &fno)) != FR_OK) return res; // tpath does not exist
|
||||||
if (fno.fattrib & AM_DIR) { // process folder contents
|
if (fno.fattrib & AM_DIR) { // process folder contents
|
||||||
DIR pdir;
|
DIR pdir;
|
||||||
TCHAR* fname = tpath + strnlen(tpath, 255);
|
TCHAR* fname = tpath + strnlen(tpath, 255);
|
||||||
@ -246,7 +250,7 @@ FRESULT worker_fvx_runlink (TCHAR* tpath) {
|
|||||||
if ((res = fa_opendir(&pdir, tpath)) != FR_OK) return res;
|
if ((res = fa_opendir(&pdir, tpath)) != FR_OK) return res;
|
||||||
*(fname++) = '/';
|
*(fname++) = '/';
|
||||||
|
|
||||||
while (f_readdir(&pdir, &fno) == FR_OK) {
|
while (fvx_readdir(&pdir, &fno) == FR_OK) {
|
||||||
if ((strncmp(fno.fname, ".", 2) == 0) || (strncmp(fno.fname, "..", 3) == 0))
|
if ((strncmp(fno.fname, ".", 2) == 0) || (strncmp(fno.fname, "..", 3) == 0))
|
||||||
continue; // filter out virtual entries
|
continue; // filter out virtual entries
|
||||||
strncpy(fname, fno.fname, tpath + 255 - fname);
|
strncpy(fname, fno.fname, tpath + 255 - fname);
|
||||||
@ -256,11 +260,11 @@ FRESULT worker_fvx_runlink (TCHAR* tpath) {
|
|||||||
worker_fvx_runlink(tpath);
|
worker_fvx_runlink(tpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f_closedir(&pdir);
|
fvx_closedir(&pdir);
|
||||||
*(--fname) = '\0';
|
*(--fname) = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
return fa_unlink( tpath );
|
return fvx_unlink( tpath );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -181,6 +181,21 @@ int WriteVirtualFile(const VirtualFile* vfile, const void* buffer, u64 offset, u
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DeleteVirtualFile(const VirtualFile* vfile) {
|
||||||
|
u8* zeroes = (u8*) TEMP_BUFFER;
|
||||||
|
u32 zeroes_size = TEMP_BUFFER_SIZE;
|
||||||
|
|
||||||
|
if (!(vfile->flags & VFLAG_DELETABLE)) return -1;
|
||||||
|
memset(zeroes, 0x00, TEMP_BUFFER_SIZE);
|
||||||
|
for (u64 pos = 0; pos < vfile->size; pos += zeroes_size) {
|
||||||
|
u64 wipe_bytes = min(zeroes_size, vfile->size - pos);
|
||||||
|
if (WriteVirtualFile(vfile, zeroes, pos, wipe_bytes, NULL) != 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
u64 GetVirtualDriveSize(const char* path) {
|
u64 GetVirtualDriveSize(const char* path) {
|
||||||
u32 virtual_src = GetVirtualSource(path);
|
u32 virtual_src = GetVirtualSource(path);
|
||||||
if (virtual_src & (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND))
|
if (virtual_src & (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND))
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
#define VFLAG_DIR (1UL<<10)
|
#define VFLAG_DIR (1UL<<10)
|
||||||
#define VFLAG_ROOT (1UL<<11)
|
#define VFLAG_ROOT (1UL<<11)
|
||||||
#define VFLAG_READONLY (1UL<<12)
|
#define VFLAG_READONLY (1UL<<12)
|
||||||
#define VFLAG_LV3 (1UL<<13)
|
#define VFLAG_DELETABLE (1UL<<13)
|
||||||
|
#define VFLAG_LV3 (1UL<<14)
|
||||||
|
|
||||||
|
|
||||||
#define VRT_DRIVES {'S', VRT_SYSNAND}, {'E', VRT_EMUNAND}, {'I', VRT_IMGNAND}, {'X', VRT_XORPAD }, \
|
#define VRT_DRIVES {'S', VRT_SYSNAND}, {'E', VRT_EMUNAND}, {'I', VRT_IMGNAND}, {'X', VRT_XORPAD }, \
|
||||||
@ -59,5 +60,6 @@ bool GetVirtualFilename(char* name, const VirtualFile* vfile, u32 n_chars);
|
|||||||
|
|
||||||
int ReadVirtualFile(const VirtualFile* vfile, void* buffer, u64 offset, u64 count, u32* bytes_read);
|
int ReadVirtualFile(const VirtualFile* vfile, void* buffer, u64 offset, u64 count, u32* bytes_read);
|
||||||
int WriteVirtualFile(const VirtualFile* vfile, const void* buffer, u64 offset, u64 count, u32* bytes_written);
|
int WriteVirtualFile(const VirtualFile* vfile, const void* buffer, u64 offset, u64 count, u32* bytes_written);
|
||||||
|
int DeleteVirtualFile(const VirtualFile* vfile);
|
||||||
|
|
||||||
u64 GetVirtualDriveSize(const char* path);
|
u64 GetVirtualDriveSize(const char* path);
|
||||||
|
@ -22,12 +22,12 @@ typedef struct {
|
|||||||
static const VirtualNandTemplate vNandTemplates[] = {
|
static const VirtualNandTemplate vNandTemplates[] = {
|
||||||
{ "nand_hdr.bin" , NP_TYPE_NCSD , NP_SUBTYPE_CTR , 0, 0 },
|
{ "nand_hdr.bin" , NP_TYPE_NCSD , NP_SUBTYPE_CTR , 0, 0 },
|
||||||
{ "twlmbr.bin" , NP_TYPE_STD , NP_SUBTYPE_TWL , 0, VFLAG_MBR },
|
{ "twlmbr.bin" , NP_TYPE_STD , NP_SUBTYPE_TWL , 0, VFLAG_MBR },
|
||||||
{ "essential.exefs" , NP_TYPE_D0K3 , NP_SUBTYPE_NONE , 0, VFLAG_ESSENTIAL },
|
{ "essential.exefs" , NP_TYPE_D0K3 , NP_SUBTYPE_NONE , 0, VFLAG_DELETABLE | VFLAG_ESSENTIAL },
|
||||||
{ "sector0x96.bin" , NP_TYPE_SECRET, NP_SUBTYPE_CTR_N, 0, VFLAG_NEEDS_OTP },
|
{ "sector0x96.bin" , NP_TYPE_SECRET, NP_SUBTYPE_CTR_N, 0, VFLAG_NEEDS_OTP },
|
||||||
{ "twln.bin" , NP_TYPE_FAT , NP_SUBTYPE_TWL , 0, 0 },
|
{ "twln.bin" , NP_TYPE_FAT , NP_SUBTYPE_TWL , 0, 0 },
|
||||||
{ "twlp.bin" , NP_TYPE_FAT , NP_SUBTYPE_TWL , 1, 0 },
|
{ "twlp.bin" , NP_TYPE_FAT , NP_SUBTYPE_TWL , 1, 0 },
|
||||||
{ "agbsave.bin" , NP_TYPE_AGB , NP_SUBTYPE_CTR , 0, 0 },
|
{ "agbsave.bin" , NP_TYPE_AGB , NP_SUBTYPE_CTR , 0, VFLAG_DELETABLE },
|
||||||
{ "gbavc.sav" , NP_TYPE_AGB , NP_SUBTYPE_CTR , 0, VFLAG_GBA_VC },
|
{ "gbavc.sav" , NP_TYPE_AGB , NP_SUBTYPE_CTR , 0, VFLAG_DELETABLE | VFLAG_GBA_VC },
|
||||||
{ "firm0.bin" , NP_TYPE_FIRM , NP_SUBTYPE_CTR , 0, 0 },
|
{ "firm0.bin" , NP_TYPE_FIRM , NP_SUBTYPE_CTR , 0, 0 },
|
||||||
{ "firm1.bin" , NP_TYPE_FIRM , NP_SUBTYPE_CTR , 1, 0 },
|
{ "firm1.bin" , NP_TYPE_FIRM , NP_SUBTYPE_CTR , 1, 0 },
|
||||||
{ "firm2.bin" , NP_TYPE_FIRM , NP_SUBTYPE_CTR , 2, 0 },
|
{ "firm2.bin" , NP_TYPE_FIRM , NP_SUBTYPE_CTR , 2, 0 },
|
||||||
@ -40,7 +40,7 @@ static const VirtualNandTemplate vNandTemplates[] = {
|
|||||||
{ "ctrnand_full.bin" , NP_TYPE_STD , NP_SUBTYPE_CTR_N, 0, 0 },
|
{ "ctrnand_full.bin" , NP_TYPE_STD , NP_SUBTYPE_CTR_N, 0, 0 },
|
||||||
{ "ctrnand_fat.bin" , NP_TYPE_FAT , NP_SUBTYPE_CTR , 0, 0 },
|
{ "ctrnand_fat.bin" , NP_TYPE_FAT , NP_SUBTYPE_CTR , 0, 0 },
|
||||||
{ "ctrnand_fat.bin" , NP_TYPE_FAT , NP_SUBTYPE_CTR_N, 0, 0 },
|
{ "ctrnand_fat.bin" , NP_TYPE_FAT , NP_SUBTYPE_CTR_N, 0, 0 },
|
||||||
{ "bonus.bin" , NP_TYPE_BONUS , NP_SUBTYPE_CTR , 0, 0 },
|
{ "bonus.bin" , NP_TYPE_BONUS , NP_SUBTYPE_CTR , 0, VFLAG_DELETABLE },
|
||||||
{ "nand.bin" , NP_TYPE_NONE , NP_SUBTYPE_NONE , 0, VFLAG_NAND_SIZE },
|
{ "nand.bin" , NP_TYPE_NONE , NP_SUBTYPE_NONE , 0, VFLAG_NAND_SIZE },
|
||||||
{ "nand_minsize.bin" , NP_TYPE_NONE , NP_SUBTYPE_NONE , 0, 0 }
|
{ "nand_minsize.bin" , NP_TYPE_NONE , NP_SUBTYPE_NONE , 0, 0 }
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user