Question about SdFat O_TRUNC flag for SD.open()

SD.open("/CHAN_1.dat",  O_TRUNC);

I'm a little confused on what this flag does, and the significance of it. Would greatly appreciate if anyone can explain, thanks.

From the SDFat documentation:

O_TRUNC - If the file exists and is a regular file, and the file is successfully opened and is not read only, its length shall be truncated to 0.

What confuses you about this?

What does its length shall be truncated to 0 means? Does that mean that all the data is removed if the file already existed before this open call?

Yes, that is exactly what it means.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.