forked from MZachmann/Qspi-FatFileStorage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QspiFstorage.h
36 lines (30 loc) · 891 Bytes
/
QspiFstorage.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
#ifndef QSPI_FSTORAGE_H
#define QSPI_FSTORAGE_H
// Copyright 2019 Mark Zachmann
#ifndef FATFS
#include <ff.h>
#endif
// provide String from somewhere
class String;
// This works well as a statically allocated object
// Create one of these and use it for file i/o
class QspiFstorage
{
public:
static QspiFstorage Store;
QspiFstorage();
virtual ~QspiFstorage();
int Initialize(void);
int Mount(bool forceClear); // mount or create the filesystem, maybe clearing it
void Ls(const char* folder);
int WriteFile(const char* filename, const String& stext);
int WriteFileN(const char* filename, const uint8_t* text, uint16_t count);
int ReadFile(const char* filename, String* pstext);
int ReadFileN(const char* filename, uint8_t* buffer, uint16_t bufmax);
void Uninitialize(void);
private:
FATFS _Filesystem;
bool _IsInitialized;
bool _IsMounted;
};
#endif