-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfat32.h
More file actions
59 lines (45 loc) · 1.22 KB
/
fat32.h
File metadata and controls
59 lines (45 loc) · 1.22 KB
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
#ifndef _FAT32_H_
#define _FAT32_H_
#include "vfs.h"
extern int CreateFATFilesystem (VFS::Device *dev);
class FATFile;
class FATFS : public VFS::Filesystem
{
friend class FATFile;
public:
FATFS (VFS::Device *d);
~FATFS() {}
int init();
static int probe (VFS::Device *dev);
virtual VFS::File *open (const char *path, int flags);
virtual VFS::Dir *opendir (const char *path) { (void)path; return 0; }
protected:
u16 bytes_per_sector;
u8 sectors_per_cluster;
u16 number_of_reserved_sectors;
u8 number_of_fats;
u32 sectors_per_fat;
u32 root_dir_first_cluster;
u32 clustersize;
};
class FATFile : public VFS::File
{
public:
FATFile (FATFS *fat, const char *filename);
~FATFile() {}
virtual int read (void *buf, int n);
virtual int write (const void *buf, int n) { (void)buf, (void)n; return -EROFS; }
virtual s64 lseek (s64 off, int whence);
virtual int error() { if (_err < 0) return -_err; return _err; }
protected:
FATFS *_fat;
VFS::Device *_device;
s32 findnextcluster (u32 prev);
int findfile (u32 start,const char *name);
int _err;
u32 cluster;
u32 length;
u32 opened;
u32 position;
};
#endif