From 96d6cb72863a49baf55beb0fcc7f4ff4f828e9b0 Mon Sep 17 00:00:00 2001 From: Kees Bakker Date: Sat, 16 Apr 2016 17:23:10 +0200 Subject: [PATCH] SD: File open with O_WRITE would always append, even when O_APPEND is off Without this fix it is not possible to open an existing file and truncate the contents. --- libraries/SD/src/SD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SD/src/SD.cpp b/libraries/SD/src/SD.cpp index 2afb9d9af1d..f5362c0fd23 100644 --- a/libraries/SD/src/SD.cpp +++ b/libraries/SD/src/SD.cpp @@ -465,7 +465,7 @@ File SDClass::open(const char *filepath, uint8_t mode) { parentdir.close(); } - if (mode & (O_APPEND | O_WRITE)) + if ((mode & (O_APPEND | O_WRITE)) == (O_APPEND | O_WRITE)) file.seekSet(file.fileSize()); return File(file, filepath); }