GodMode9/source/virtual/virtual.h

56 lines
1.8 KiB
C
Raw Normal View History

2016-03-21 18:29:55 +01:00
#pragma once
#include "common.h"
2016-11-15 23:06:01 +01:00
#include "dir.h"
2016-03-21 18:29:55 +01:00
#include "nand.h"
2016-04-04 22:45:49 +02:00
#define VRT_SYSNAND NAND_SYSNAND
#define VRT_EMUNAND NAND_EMUNAND
#define VRT_IMGNAND NAND_IMGNAND
2016-04-09 21:50:50 +02:00
#define VRT_MEMORY (1<<10)
#define VRT_GAME (1<<11)
2016-11-28 16:30:49 +01:00
#define VRT_SOURCE (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND|VRT_MEMORY|VRT_GAME)
2016-04-22 17:47:13 +02:00
#define VFLAG_A9LH_AREA (1<<20)
2016-11-28 16:30:49 +01:00
#define VFLAG_DIR (1<<21)
#define VFLAG_ROOT (1<<22)
// virtual file flag (subject to change):
// bits 0...9 : reserved for NAND virtual sources and info
// bits 10...15: reserved for other virtual sources
2016-11-28 01:19:12 +01:00
// bits 16...19: reserved for external flags
// bits 20...31: reserved for internal flags (different per source)
2016-03-21 18:29:55 +01:00
typedef struct {
char name[32];
2016-11-28 16:30:49 +01:00
u64 offset; // must be a multiple of 0x200 (for NAND access)
u64 size;
2016-03-21 18:29:55 +01:00
u32 keyslot;
u32 flags;
} __attribute__((packed)) VirtualFile;
2016-11-28 16:30:49 +01:00
// virtual dirs are only relevant for virtual game drives
typedef struct {
int index;
u64 offset;
u64 size;
u32 flags;
u32 virtual_src;
} __attribute__((packed)) VirtualDir;
2016-04-09 21:56:42 +02:00
u32 GetVirtualSource(const char* path);
bool CheckVirtualDrive(const char* path);
2016-11-28 21:21:42 +01:00
bool ReadVirtualDir(VirtualFile* vfile, VirtualDir* vdir);
bool OpenVirtualRoot(VirtualDir* vdir, u32 virtual_src);
bool OpenVirtualDir(VirtualDir* vdir, VirtualFile* ventry);
2016-11-15 23:34:21 +01:00
bool GetVirtualFile(VirtualFile* vfile, const char* path);
2016-11-28 21:21:42 +01:00
bool GetVirtualDir(VirtualDir* vdir, const char* path);
bool GetVirtualDirContents(DirStruct* contents, char* fpath, int fnsize, const char* pattern, bool recursive);
2016-11-28 21:21:42 +01:00
bool GetVirtualFilename(char* name, const VirtualFile* vfile, u32 n_chars);
int ReadVirtualFile(const VirtualFile* vfile, u8* buffer, u32 offset, u32 count, u32* bytes_read);
int WriteVirtualFile(const VirtualFile* vfile, const u8* buffer, u32 offset, u32 count, u32* bytes_written);