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
|
#ifndef _REPRAPSDCARD_H_
#define _REPRAPSDCARD_H_
#include "sd_raw.h"
#include "sd_raw_config.h"
#include "sd_reader_config.h"
#include "partition.h"
#include "partition_config.h"
#include "fat.h"
typedef struct fat_file_struct File;
class RepRapSDCard
{
public:
enum SDStatus {
SDOK = 0,
INIT_FAILED,
NO_CARD,
NO_PARTITION,
NO_FILESYS,
NO_ROOT
};
partition_struct *partition; // Current partition
fat_fs_struct *filesystem; // Current filesystem
fat_dir_struct *cwd; // Current open directory
public:
RepRapSDCard() { }
uint8_t init();
void printInfo();
bool getNextEntry(char *name);
bool openDir(const char *path);
File *openFile(const char *name);
void closeFile(File *f) { fat_close_file(f); }
uint16_t readFile(File *f, uint8_t* buffer, uint16_t buffer_len) {
return fat_read_file(f, buffer, buffer_len);
}
uint8_t create_file(char *name);
uint8_t seek_file(File *f, int32_t *offset, uint8_t whence) {
return fat_seek_file(f, offset, whence);
}
uint8_t reset_file(File *f) { return fat_seek_file(f, 0, FAT_SEEK_SET); }
uint8_t write_file(File *f, uint8_t *buff, uint8_t num) {
return fat_write_file(f, buff, num);
}
private:
bool open_partition();
bool open_filesys();
};
#endif
|