In what other ways are FILE_READ and FILE_WRITE different than the fact that you can actually use print in FILE_WRITE mode?
"Other than the fact that you can write to a file opened using FILE_WRITE" seems to gloss over the fact that FILE_WRITE means that you CAN write to the file.
guess that the above might be faster? or else why do you have it at all?
Opening the file for read and write is not slower than opening it for read only. Opening it read-only ensures that you can't actually write to it.
NOTE: saw that FILE_WRITE starts at the end of the file too.
That depends on other settings. O_TRUNC and O_APPEND position the cursor in different places.
i should be able to use aFile.seek(0); to move to the front? right?
Yes.
You are talking about "append mode" and "truncate mode", never herd of those and never came across any examples with those within, care to explain how I could use this modes to my advantage?
Look at how FILE_READ and FILE_WRITE are defined.
#define FILE_READ O_READ
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT)
You can OR on other attributes when you open the file. O_APPEND and O_TRUNC are just two of the other attributes.
SdFile.cpp contains:
/**
* Open a file or directory by name.
*
* \param[in] dirFile An open SdFat instance for the directory containing the
* file to be opened.
*
* \param[in] fileName A valid 8.3 DOS name for a file to be opened.
*
* \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive
* OR of flags from the following list
*
* 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.
*
* \note Directory files must be opened read only. Write and truncation is
* not allowed for directory files.
*
* \return The value one, true, is returned for success and
* the value zero, false, is returned for failure.
* Reasons for failure include this SdFile is already open, \a difFile is not
* a directory, \a fileName is invalid, the file does not exist
* or can't be opened in the access mode specified by oflag.
*/