Skip to content

Commit 911a13e

Browse files
Apply SD.h fix from ESP8266
Pull in the portion of the change correcting the flag setting from esp8266/Arduino#8833
1 parent b6cb2e7 commit 911a13e

File tree

1 file changed

+17
-3
lines changed
  • libraries/SD/src

1 file changed

+17
-3
lines changed

libraries/SD/src/SD.h

+17-3
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,23 @@ class SDClass {
162162

163163
private:
164164
const char *getMode(uint8_t mode) {
165-
bool read = (mode & O_READ) ? true : false;
166-
bool write = (mode & O_WRITE) ? true : false;
167-
bool append = (mode & O_APPEND) ? true : false;
165+
bool read = false;
166+
bool write = false;
167+
168+
switch (mode & O_ACCMODE) {
169+
case O_RDONLY:
170+
read = true;
171+
break;
172+
case O_WRONLY:
173+
write = true;
174+
break;
175+
case O_RDWR:
176+
read = true;
177+
write = true;
178+
break;
179+
}
180+
const bool append = (mode & O_APPEND) > 0;
181+
168182
if (read & !write) {
169183
return "r";
170184
} else if (!read & write & !append) {

0 commit comments

Comments
 (0)