@@ -14,184 +14,184 @@ class FileSdFatMMC : public SdFile
1414#endif
1515
1616{
17- public:
17+ public:
1818
19- FileSdFatMMC ()
20- {
21- if (USE_SPI_MICROSD)
22- _sdFile = new SdFile;
19+ FileSdFatMMC ()
20+ {
21+ if (USE_SPI_MICROSD)
22+ _sdFile = new SdFile;
2323#ifdef COMPILE_SD_MMC
24- else
25- _file = new File;
24+ else
25+ _file = new File;
2626#endif
27- };
28-
29- ~FileSdFatMMC ()
30- {
31- if (USE_SPI_MICROSD)
27+ };
28+
29+ ~FileSdFatMMC ()
3230 {
33- ;
34- // if (_sdFile) // operator bool
35- // delete _sdFile;
36- }
31+ if (USE_SPI_MICROSD)
32+ {
33+ ;
34+ // if (_sdFile) // operator bool
35+ // delete _sdFile;
36+ }
3737#ifdef COMPILE_SD_MMC
38- else
39- {
40- ;
41- // if (_file) // operator bool
42- // delete _file;
43- }
38+ else
39+ {
40+ ;
41+ // if (_file) // operator bool
42+ // delete _file;
43+ }
4444#endif
45- };
45+ };
4646
47- operator bool ()
48- {
49- if (USE_SPI_MICROSD)
50- return _sdFile;
47+ operator bool ()
48+ {
49+ if (USE_SPI_MICROSD)
50+ return _sdFile;
5151#ifdef COMPILE_SD_MMC
52- else
53- return _file;
52+ else
53+ return _file;
5454#endif
55- };
55+ };
5656
57- size_t println (const char printMe[])
58- {
59- if (USE_SPI_MICROSD)
60- return _sdFile->println (printMe);
57+ size_t println (const char printMe[])
58+ {
59+ if (USE_SPI_MICROSD)
60+ return _sdFile->println (printMe);
6161#ifdef COMPILE_SD_MMC
62- else
63- return _file->println (printMe);
62+ else
63+ return _file->println (printMe);
6464#endif
65- };
65+ };
6666
67- bool open (const char *filepath, oflag_t mode)
68- {
69- if (USE_SPI_MICROSD)
67+ bool open (const char *filepath, oflag_t mode)
7068 {
71- if (_sdFile->open (filepath, mode) == true )
72- return true ;
73- return false ;
74- }
69+ if (USE_SPI_MICROSD)
70+ {
71+ if (_sdFile->open (filepath, mode) == true )
72+ return true ;
73+ return false ;
74+ }
7575#ifdef COMPILE_SD_MMC
76- else
76+ else
77+ {
78+ if (mode & O_APPEND)
79+ *_file = SD_MMC.open (filepath, FILE_APPEND);
80+ else if (mode & O_WRITE)
81+ *_file = SD_MMC.open (filepath, FILE_WRITE);
82+ else // if (mode & O_READ)
83+ *_file = SD_MMC.open (filepath, FILE_READ);
84+ if (_file) // operator bool
85+ return true ;
86+ return false ;
87+ }
88+ #endif
89+ };
90+
91+ uint32_t size ()
7792 {
78- if (mode & O_APPEND)
79- *_file = SD_MMC.open (filepath, FILE_APPEND);
80- else if (mode & O_WRITE)
81- *_file = SD_MMC.open (filepath, FILE_WRITE);
82- else // if (mode & O_READ)
83- *_file = SD_MMC.open (filepath, FILE_READ);
84- if (_file) // operator bool
85- return true ;
86- return false ;
87- }
88- #endif
89- };
90-
91- uint32_t size ()
92- {
93- if (USE_SPI_MICROSD)
94- return _sdFile->size ();
93+ if (USE_SPI_MICROSD)
94+ return _sdFile->size ();
9595#ifdef COMPILE_SD_MMC
96- else
97- return _file->size ();
98- #endif
99- };
96+ else
97+ return _file->size ();
98+ #endif
99+ };
100100
101- uint32_t position ()
102- {
103- if (USE_SPI_MICROSD)
104- return _sdFile->position ();
101+ uint32_t position ()
102+ {
103+ if (USE_SPI_MICROSD)
104+ return _sdFile->position ();
105105#ifdef COMPILE_SD_MMC
106- else
107- return _file->position ();
108- #endif
109- };
106+ else
107+ return _file->position ();
108+ #endif
109+ };
110110
111- int available ()
112- {
113- if (USE_SPI_MICROSD)
114- return _sdFile->available ();
111+ int available ()
112+ {
113+ if (USE_SPI_MICROSD)
114+ return _sdFile->available ();
115115#ifdef COMPILE_SD_MMC
116- else
117- return _file->available ();
118- #endif
119- };
116+ else
117+ return _file->available ();
118+ #endif
119+ };
120120
121- int read (uint8_t *buf, uint16_t nbyte)
122- {
123- if (USE_SPI_MICROSD)
124- return _sdFile->read (buf, nbyte);
121+ int read (uint8_t *buf, uint16_t nbyte)
122+ {
123+ if (USE_SPI_MICROSD)
124+ return _sdFile->read (buf, nbyte);
125125#ifdef COMPILE_SD_MMC
126- else
127- return _file->read (buf, nbyte);
128- #endif
129- };
126+ else
127+ return _file->read (buf, nbyte);
128+ #endif
129+ };
130130
131- size_t write (const uint8_t *buf, size_t size)
132- {
133- if (USE_SPI_MICROSD)
134- return _sdFile->write (buf, size);
131+ size_t write (const uint8_t *buf, size_t size)
132+ {
133+ if (USE_SPI_MICROSD)
134+ return _sdFile->write (buf, size);
135135#ifdef COMPILE_SD_MMC
136- else
137- return _file->write (buf, size);
138- #endif
139- };
136+ else
137+ return _file->write (buf, size);
138+ #endif
139+ };
140140
141- void close ()
142- {
143- if (USE_SPI_MICROSD)
144- _sdFile->close ();
141+ void close ()
142+ {
143+ if (USE_SPI_MICROSD)
144+ _sdFile->close ();
145145#ifdef COMPILE_SD_MMC
146- else
147- _file->close ();
148- #endif
149- };
146+ else
147+ _file->close ();
148+ #endif
149+ };
150150
151- void updateFileAccessTimestamp ()
152- {
153- if (USE_SPI_MICROSD)
151+ void updateFileAccessTimestamp ()
154152 {
155- if (online. rtc == true )
153+ if (USE_SPI_MICROSD )
156154 {
157- // ESP32Time returns month:0-11
158- _sdFile->timestamp (T_ACCESS, rtc.getYear (), rtc.getMonth () + 1 , rtc.getDay (), rtc.getHour (true ), rtc.getMinute (), rtc.getSecond ());
159- _sdFile->timestamp (T_WRITE, rtc.getYear (), rtc.getMonth () + 1 , rtc.getDay (), rtc.getHour (true ), rtc.getMinute (), rtc.getSecond ());
155+ if (online.rtc == true )
156+ {
157+ // ESP32Time returns month:0-11
158+ _sdFile->timestamp (T_ACCESS, rtc.getYear (), rtc.getMonth () + 1 , rtc.getDay (), rtc.getHour (true ), rtc.getMinute (), rtc.getSecond ());
159+ _sdFile->timestamp (T_WRITE, rtc.getYear (), rtc.getMonth () + 1 , rtc.getDay (), rtc.getHour (true ), rtc.getMinute (), rtc.getSecond ());
160+ }
160161 }
161- }
162- };
162+ };
163163
164- void updateFileCreateTimestamp ()
165- {
166- if (USE_SPI_MICROSD)
164+ void updateFileCreateTimestamp ()
167165 {
168- if (online. rtc == true )
166+ if (USE_SPI_MICROSD )
169167 {
170- _sdFile->timestamp (T_CREATE, rtc.getYear (), rtc.getMonth () + 1 , rtc.getDay (), rtc.getHour (true ), rtc.getMinute (), rtc.getSecond ()); // ESP32Time returns month:0-11
168+ if (online.rtc == true )
169+ {
170+ _sdFile->timestamp (T_CREATE, rtc.getYear (), rtc.getMonth () + 1 , rtc.getDay (), rtc.getHour (true ), rtc.getMinute (), rtc.getSecond ()); // ESP32Time returns month:0-11
171+ }
171172 }
172- }
173- };
173+ };
174174
175- void sync ()
176- {
177- if (USE_SPI_MICROSD)
178- _sdFile->sync ();
179- };
175+ void sync ()
176+ {
177+ if (USE_SPI_MICROSD)
178+ _sdFile->sync ();
179+ };
180180
181- int fileSize ()
182- {
183- if (USE_SPI_MICROSD)
184- return _sdFile->fileSize ();
181+ int fileSize ()
182+ {
183+ if (USE_SPI_MICROSD)
184+ return _sdFile->fileSize ();
185185#ifdef COMPILE_SD_MMC
186- else
187- return _file->fileSize ();
188- #endif
189- };
186+ else
187+ return _file->fileSize ();
188+ #endif
189+ };
190190
191- protected:
192- SdFile * _sdFile;
191+ protected:
192+ SdFile * _sdFile;
193193#ifdef COMPILE_SD_MMC
194- File * _file;
194+ File * _file;
195195#endif
196196};
197197
0 commit comments