-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileIO.h
More file actions
32 lines (29 loc) · 952 Bytes
/
fileIO.h
File metadata and controls
32 lines (29 loc) · 952 Bytes
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
#ifndef FILEIO_H
#define FILEIO_H
#include<SD.h>
#include<SPI.h>
#include<string>
#include<ArduinoJson.h>
#include<Arduino.h>
#include<cstring>
#include<cstdlib>
/* the file IO depends on the SD cart slot of MKR Env Shield*/
class FileIOHandler
{
public:
FileIOHandler();
void init();
void closeFile();
char* readFile(const char* fileName);
void writeFile(const char* fileName, const char* content); // this will not overwrite the file, only append to it
JsonDocument readJson(const char* fileName); // this can read json object from a JSON file
const char* getFileName();
void deleteFile(const char* fileName);
void cleanFile(const char* fileName); // this is usually called before writing data into a file
bool exists(const char* fileName);
private:
std::string fileName="";
File myFile;
JsonDocument jsonObject;
};
#endif