forked from MiSTer-devel/Main_MiSTer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_io.h
124 lines (98 loc) · 3.56 KB
/
file_io.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef _FAT16_H_INCLUDED
#define _FAT16_H_INCLUDED
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include "spi.h"
struct fileZipArchive;
struct fileTYPE
{
fileTYPE();
int opened();
FILE *filp;
int mode;
int type;
fileZipArchive *zip;
__off64_t size;
__off64_t offset;
char path[1024];
char name[261];
};
struct direntext_t
{
dirent de;
int cookie;
char datecode[16];
char altname[256];
};
int flist_nDirEntries();
int flist_iFirstEntry();
void flist_iFirstEntryInc();
int flist_iSelectedEntry();
direntext_t* flist_DirItem(int n);
direntext_t* flist_SelectedItem();
// scanning flags
#define SCANF_INIT 0 // start search from beginning of directory
#define SCANF_NEXT 1 // find next file in directory
#define SCANF_PREV -1 // find previous file in directory
#define SCANF_NEXT_PAGE 2 // find next 16 files in directory
#define SCANF_PREV_PAGE -2 // find previous 16 files in directory
#define SCANF_SET_ITEM 3 // find exact item
#define SCANF_END 4 // find last file in directory
// options flags
#define SCANO_DIR 1 // include subdirectories
#define SCANO_UMOUNT 2 // allow backspace key
#define SCANO_CORES 4 // only include subdirectories with prefix '_'
#define SCANO_TXT 8
#define SCANO_NEOGEO 16
#define SCANO_NOENTER 32
void FindStorage();
int getStorage(int from_setting);
void setStorage(int dev);
int isUSBMounted();
int FileOpenZip(fileTYPE *file, const char *name, uint32_t crc32);
int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute = 0);
int FileOpen(fileTYPE *file, const char *name, char mute = 0);
void FileClose(fileTYPE *file);
__off64_t FileGetSize(fileTYPE *file);
int FileSeek(fileTYPE *file, __off64_t offset, int origin);
int FileSeekLBA(fileTYPE *file, uint32_t offset);
int FileReadAdv(fileTYPE *file, void *pBuffer, int length);
int FileReadSec(fileTYPE *file, void *pBuffer);
int FileWriteAdv(fileTYPE *file, void *pBuffer, int length);
int FileWriteSec(fileTYPE *file, void *pBuffer);
void FileCreatePath(const char *dir);
int FileExists(const char *name);
int FileCanWrite(const char *name);
int PathIsDir(const char *name);
#define SAVE_DIR "saves"
void FileGenerateSavePath(const char *name, char* out_name);
#define SAVESTATE_DIR "savestates"
void FileGenerateSavestatePath(const char *name, char* out_name);
#define SCREENSHOT_DIR "screenshots"
#define SCREENSHOT_DEFAULT "screen"
void FileGenerateScreenshotName(const char *name, char *out_name, int buflen);
int FileSave(const char *name, void *pBuffer, int size);
int FileLoad(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
int FileDelete(const char *name);
//save/load from config dir
#define CONFIG_DIR "config"
int FileSaveConfig(const char *name, void *pBuffer, int size);
int FileLoadConfig(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
int FileDeleteConfig(const char *name);
void AdjustDirectory(char *path);
int ScanDirectory(char* path, int mode, const char *extension, int options, const char *prefix = NULL);
void prefixGameDir(char *dir, size_t dir_len);
int findPrefixDir(char *dir, size_t dir_len);
const char *getStorageDir(int dev);
const char *getRootDir();
const char *getFullPath(const char *name);
uint32_t getFileType(const char *name);
bool isMraName(char *path);
#define LOADBUF_SZ (1024*1024)
#define COEFF_DIR "filters"
#define GAMMA_DIR "gamma"
#define GAMES_DIR "games"
#define CIFS_DIR "cifs"
#endif