SdFat-Particle icon indicating copy to clipboard operation
SdFat-Particle copied to clipboard

FatFile::open() fails creating new file with O_AT_END flag

Open gitjoost opened this issue 7 years ago • 2 comments

open(fileName, O_CREAT | O_WRITE | O_AT_END) fails if <fileName> does not exist.

gitjoost avatar Mar 02 '18 02:03 gitjoost

I ran the following program with a freshly formatted SD and the file test.txt was created.

The program printed:

Done

// This #include statement was automatically added by the Particle IDE.
#include <SdFat.h>
SdFat sd;
File file;
void setup() {
    Serial.begin(9600);
    Serial.println("type any character");
    while (!Serial.available()) {}
    if (!sd.begin()) {
        Serial.println("begin");
    }
    if (!file.open("test.txt", O_CREAT | O_WRITE | O_AT_END)) {
        Serial.println("open");
    }
    file.close();
    Serial.println("Done");
}
void loop() {
}

I used a photon and the Particle web ide with firmware 6.3.

greiman avatar Mar 02 '18 15:03 greiman

hmm, thanks for checking this Bill, a similar test fails consistently on my side. If I use O_CREAT | O_WRITE flags only, it works just peachy. But with O_AT_END as the third flag, file creation fails. I guess I have to dig in to see whats going on.

gitjoost avatar Mar 02 '18 16:03 gitjoost