Open Font Render 1.2
Loading...
Searching...
No Matches
M5Stack_SD_Preset.h
Go to the documentation of this file.
1// -------------------------------------------------------
2// M5Stack_SD_Preset.h
3//
4// Copyright (c) 2021 takkaO
5//
6// If you use, modify, or redistribute this file independently
7// of the original repository, this program is licensed under
8// the MIT License.
9//
10// If you use, modify or redistribute this file as part of
11// the original repository, please follow the repository's license.
12//
13// -------------------------------------------------------
14
15#ifndef OFR_M5STACK_SD_PRESET_H
16#define OFR_M5STACK_SD_PRESET_H
17
18#include <SD.h>
19#include <list>
20
21std::list<File> ofr_file_list; // For multiple file loading
22
23FT_FILE *OFR_fopen(const char *filename, const char *mode) {
24 File f = SD.open(filename, mode);
25 ofr_file_list.push_back(f);
26 return &ofr_file_list.back();
27}
28
29void OFR_fclose(FT_FILE *stream) {
30 ((File *)stream)->close();
31}
32
33size_t OFR_fread(void *ptr, size_t size, size_t nmemb, FT_FILE *stream) {
34 return ((File *)stream)->read((uint8_t *)ptr, size * nmemb);
35}
36
37int OFR_fseek(FT_FILE *stream, long int offset, int whence) {
38 return ((File *)stream)->seek(offset, (SeekMode)whence);
39}
40
41long int OFR_ftell(FT_FILE *stream) {
42 return ((File *)stream)->position();
43}
44
45#endif /* OFR_M5STACK_SD_PRESET_H */
#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: M5Stack_SD_Preset.h:37
long int OFR_ftell(FT_FILE *stream)
Get file cursor position.
Definition: M5Stack_SD_Preset.h:41
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: M5Stack_SD_Preset.h:33
FT_FILE * OFR_fopen(const char *filename, const char *mode)
Open file and get file pointer.
Definition: M5Stack_SD_Preset.h:23
std::list< File > ofr_file_list
Definition: M5Stack_SD_Preset.h:21
void OFR_fclose(FT_FILE *stream)
Close file.
Definition: M5Stack_SD_Preset.h:29