Go Down

Topic: delete the text into the file (Read 897 times) previous topic - next topic


hello, there are any way to delete the text into a file on the sd card without you need remove or delete the file.



read the section in memory, change it, and save it back

which lib are you using, it seems kind of complicated with SDFATlib, might not be possible with the standard library included, dont know I never use it


hello, there are any way to delete the text into a file on the sd card without you need remove or delete the file.

Open the file for write, in replace mode (not the default append mode). Close the file without actually writing anything.


Can you tell me how the 'replace' mode is implemented please?  I've been wrestling with trying to stop appending data to the file for two days, now and about to start looking for a tall building to jump off.


This is from SdFile.cpp:
Code: [Select]
* O_READ - Open for reading.
* O_RDONLY - Same as O_READ.
* O_WRITE - Open for writing.
* O_WRONLY - Same as O_WRITE.
* O_RDWR - Open for reading and writing.
* O_APPEND - If set, the file offset shall be set to the end of the
* file prior to each write.
* O_CREAT - If the file exists, this flag has no effect except as noted
* under O_EXCL below. Otherwise, the file shall be created
* O_EXCL - If O_CREAT and O_EXCL are set, open() shall fail if the file exists.
* O_SYNC - Call sync() after each write.  This flag should not be used with
* write(uint8_t), write_P(PGM_P), writeln_P(PGM_P), or the Arduino Print class.
* These functions do character at a time writes so sync() will be called
* after each byte.
* 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.

Each of the values can be OR'd together to open the file exactly the way that you want. The way to open the file is the 2nd argument to the open() method. To open a file for writing, creating it if doesn't exist, and deleting any data in the file if it does, use O_WRITE | O_CREAT | O_TRUNC.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131