Open file for write should truncate file to match SD.h implementation

This commit is contained in:
Dave Allie 2025-12-30 15:59:38 +11:00
parent 0d269feed2
commit bf642c496d
No known key found for this signature in database
GPG Key ID: F2FDDB3AD8D0276F

View File

@ -208,7 +208,7 @@ bool SDCardManager::openFileForRead(const char* moduleName, const char* path, Fs
return false;
}
file = sd.open(path, FILE_READ);
file = sd.open(path, O_RDONLY);
if (!file) {
Serial.printf("[%lu] [%s] Failed to open file for reading: %s\n", millis(), moduleName, path);
return false;
@ -225,7 +225,7 @@ bool SDCardManager::openFileForRead(const char* moduleName, const String& path,
}
bool SDCardManager::openFileForWrite(const char* moduleName, const char* path, FsFile& file) {
file = sd.open(path, FILE_WRITE);
file = sd.open(path, O_RDWR | O_CREAT | O_TRUNC);
if (!file) {
Serial.printf("[%lu] [%s] Failed to open file for writing: %s\n", millis(), moduleName, path);
return false;