Standardize File handling with FsHelpers (#110)

## Summary

* Standardize File handling with FsHelpers
* Better central place to manage to logic of if files exist/open for
reading/writing
This commit is contained in:
Dave Allie
2025-12-23 14:14:10 +11:00
committed by GitHub
parent 66ddb52103
commit 1107590b56
20 changed files with 315 additions and 221 deletions

View File

@@ -1,6 +1,7 @@
#include "CrossPointWebServer.h"
#include <ArduinoJson.h>
#include <FsHelpers.h>
#include <SD.h>
#include <WiFi.h>
@@ -339,8 +340,7 @@ void CrossPointWebServer::handleUpload() const {
}
// Open file for writing
uploadFile = SD.open(filePath.c_str(), FILE_WRITE);
if (!uploadFile) {
if (!FsHelpers::openFileForWrite("WEB", filePath, uploadFile)) {
uploadError = "Failed to create file on SD card";
Serial.printf("[%lu] [WEB] [UPLOAD] FAILED to create file: %s\n", millis(), filePath.c_str());
return;