-
Notifications
You must be signed in to change notification settings - Fork 0
/
drive.h
87 lines (71 loc) · 2.79 KB
/
drive.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
/**
drive.h - Drive interface
Copyright (C) 2020 Costin STROIE <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DRIVE_H
#define DRIVE_H
#include "Arduino.h"
#include <SD.h>
#include "global.h"
#include "config.h"
#ifdef SPI_RAM
#include "spiram.h"
typedef SPIRAM RAM;
#else
#include "mcuram.h"
typedef MCURAM RAM;
#endif
class DRIVE {
public:
DRIVE(RAM *ram, char *bdir = "");
~DRIVE();
void init();
bool loadCCP(bool verbose = false);
void mkDir(uint8_t drive, uint8_t user);
bool selDrive(uint8_t drive);
uint32_t fileSize(char* fname, uint8_t mode = FILE_READ);
uint8_t findFirst(char* fname, uint32_t &fsize);
uint8_t findNext(char* fname, uint32_t &fsize);
uint8_t checkSUB(uint8_t drive, uint8_t user);
uint8_t read(uint16_t ramDMA, char* fname, uint32_t fpos);
uint8_t write(uint16_t ramDMA, char* fname, uint32_t fpos);
bool check(char* fname, uint8_t mode = FILE_READ);
bool open(char* fname, uint8_t mode = FILE_READ);
void close(char* fname);
bool create(char* fname);
bool remove(char* fname);
bool rename(char* fname, char* newname);
bool truncate(char* fname, uint8_t rec);
bool ckLST();
void wrLST(char c);
void fsLST();
void clLST();
private:
RAM *ram;
void ledOn();
void ledOff();
uint8_t fname2cname(char *fname, char *cname);
void cname2fname(char *cname, char *fname);
bool match(char *cname, char* pattern);
char *bDir; // Base directory on SD card
char fPath[64]; // Base file path
char fDrive; // The drive letter of the file to find
char fUser; // The user hex code of the file to find
char fPattern[12]; // File name pattern for searching
File file; // Current file in use
File fDir; // The directory to look into
uint8_t lstMode; // Last file open mode
File devLST; // The LIST device as file
uint32_t tsLST; // The LIST device timestamp
};
#endif /* DRIVE_H */