]> granicus.if.org Git - esp-idf/commitdiff
Fix fopen() in “a” (append) mode
authornineisk <is_kk@hotmail.com>
Thu, 26 Jan 2017 02:30:12 +0000 (09:30 +0700)
committerAngus Gratton <angus@espressif.com>
Tue, 14 Feb 2017 05:15:08 +0000 (16:15 +1100)
fopen() does not work when file is opened in “a” (append) mode

components/fatfs/src/vfs_fat.c

index 4ef387b43bab8d6eb34ad69252398b7384b3b7bf..73bed5eaa1a30d6bfe93f74ed9e10c87a79ba171 100644 (file)
@@ -152,7 +152,7 @@ static int fat_mode_conv(int m)
     }
     if ((m & O_CREAT) && (m & O_EXCL)) {
         res |= FA_CREATE_NEW;
-    } else if (m & O_CREAT) {
+    } else if ((m & O_CREAT) && (m & O_TRUNC)) {
         res |= FA_CREATE_ALWAYS;
     } else if (m & O_APPEND) {
         res |= FA_OPEN_ALWAYS;