15#ifndef OFR_WIO_TERMINAL_SD_PRESET_H
16#define OFR_WIO_TERMINAL_SD_PRESET_H
19#include <Seeed_Arduino_FS.h>
26 if (strcmp(mode,
"r") == 0) {
27 f = SD.open(filename, FA_READ);
28 }
else if (strcmp(mode,
"r+") == 0) {
29 f = SD.open(filename, FA_READ | FA_WRITE);
30 }
else if (strcmp(mode,
"w") == 0) {
31 f = SD.open(filename, FA_CREATE_ALWAYS | FA_WRITE);
32 }
else if (strcmp(mode,
"w+") == 0) {
33 f = SD.open(filename, FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
34 }
else if (strcmp(mode,
"a") == 0) {
35 f = SD.open(filename, FA_OPEN_APPEND | FA_WRITE);
36 }
else if (strcmp(mode,
"a+") == 0) {
37 f = SD.open(filename, FA_OPEN_APPEND | FA_WRITE | FA_READ);
38 }
else if (strcmp(mode,
"wx") == 0) {
39 f = SD.open(filename, FA_CREATE_NEW | FA_WRITE);
40 }
else if (strcmp(mode,
"w+x") == 0) {
41 f = SD.open(filename, FA_CREATE_NEW | FA_WRITE | FA_READ);
43 f = SD.open(filename, FA_READ);
50 ((File *)stream)->close();
54 return ((File *)stream)->read((uint8_t *)ptr, size * nmemb);
58 return ((File *)stream)->seek(offset, (SeekMode)whence);
62 return ((File *)stream)->position();
#define FT_FILE
Definition: FileSupport.h:16
int OFR_fseek(FT_FILE *stream, long int offset, int whence)
Moves the cursor to the specified position.
Definition: WioTerminal_SD_Preset.h:57
long int OFR_ftell(FT_FILE *stream)
Get file cursor position.
Definition: WioTerminal_SD_Preset.h:61
size_t OFR_fread(void *ptr, size_t size, size_t nmemb, FT_FILE *stream)
Read data from a file and store it in a buffer.
Definition: WioTerminal_SD_Preset.h:53
FT_FILE * OFR_fopen(const char *filename, const char *mode)
Open file and get file pointer.
Definition: WioTerminal_SD_Preset.h:24
std::list< File > ofr_file_list
Definition: WioTerminal_SD_Preset.h:22
void OFR_fclose(FT_FILE *stream)
Close file.
Definition: WioTerminal_SD_Preset.h:49