refactor: Drop FsFile alias, use HalFile in downstream code (#2141)

This commit is contained in:
Zach Nelson
2026-05-25 16:26:54 -04:00
committed by GitHub
parent d7797baff2
commit e9120888fa
63 changed files with 201 additions and 205 deletions
+16 -12
View File
@@ -35,7 +35,7 @@ constexpr uint16_t LOCAL_UDP_PORT = 8134;
CrossPointWebServer* wsInstance = nullptr;
// WebSocket upload state
FsFile wsUploadFile;
HalFile wsUploadFile;
String wsUploadFileName;
String wsUploadPath;
size_t wsUploadSize = 0;
@@ -374,7 +374,7 @@ void CrossPointWebServer::handleStatus() const {
}
void CrossPointWebServer::scanFiles(const char* path, const std::function<void(FileInfo)>& callback) const {
FsFile root = Storage.open(path);
HalFile root = Storage.open(path);
if (!root) {
LOG_DBG("WEB", "Failed to open directory: %s", path);
return;
@@ -388,7 +388,7 @@ void CrossPointWebServer::scanFiles(const char* path, const std::function<void(F
LOG_DBG("WEB", "Scanning files in: %s", path);
FsFile file = root.openNextFile();
HalFile file = root.openNextFile();
char name[500];
while (file) {
file.getName(name, sizeof(name));
@@ -519,7 +519,7 @@ void CrossPointWebServer::handleDownload() const {
return;
}
FsFile file = Storage.open(itemPath.c_str());
HalFile file = Storage.open(itemPath.c_str());
if (!file) {
server->send(500, "text/plain", "Failed to open file");
return;
@@ -842,7 +842,7 @@ void CrossPointWebServer::handleRename() const {
return;
}
FsFile file = Storage.open(itemPath.c_str());
HalFile file = Storage.open(itemPath.c_str());
if (!file) {
server->send(500, "text/plain", "Failed to open file");
return;
@@ -918,7 +918,7 @@ void CrossPointWebServer::handleMove() const {
return;
}
FsFile file = Storage.open(itemPath.c_str());
HalFile file = Storage.open(itemPath.c_str());
if (!file) {
server->send(500, "text/plain", "Failed to open file");
return;
@@ -934,7 +934,7 @@ void CrossPointWebServer::handleMove() const {
server->send(404, "text/plain", "Destination not found");
return;
}
FsFile destDir = Storage.open(destPath.c_str());
HalFile destDir = Storage.open(destPath.c_str());
if (!destDir || !destDir.isDirectory()) {
if (destDir) {
destDir.close();
@@ -1064,10 +1064,10 @@ void CrossPointWebServer::handleDelete() const {
// Decide whether it's a directory or file by opening it
bool success = false;
FsFile f = Storage.open(itemPath.c_str());
HalFile f = Storage.open(itemPath.c_str());
if (f && f.isDirectory()) {
// For folders, ensure empty before removing
FsFile entry = f.openNextFile();
HalFile entry = f.openNextFile();
if (entry) {
entry.close();
f.close();
@@ -1741,7 +1741,7 @@ void CrossPointWebServer::handleFontList() const {
fileObj["name"] = name ? name + 1 : file.path.c_str();
// Stat the file for size
FsFile f;
HalFile f;
if (Storage.openFileForRead("WEB", file.path.c_str(), f)) {
fileObj["size"] = static_cast<unsigned long>(f.size());
f.close();
@@ -1848,7 +1848,9 @@ void CrossPointWebServer::handleFontUploadData() {
fontUpload.bytesWritten += fontUpload.bufferPos;
fontUpload.bufferPos = 0;
}
fontUpload.file.close();
if (fontUpload.file) {
fontUpload.file.close();
}
if (!fontUpload.valid && !fontUpload.filePath.empty()) {
Storage.remove(fontUpload.filePath.c_str());
@@ -1859,7 +1861,9 @@ void CrossPointWebServer::handleFontUploadData() {
}
case UPLOAD_FILE_ABORTED: {
fontUpload.file.close();
if (fontUpload.file) {
fontUpload.file.close();
}
if (!fontUpload.filePath.empty()) {
Storage.remove(fontUpload.filePath.c_str());
}
+2 -2
View File
@@ -31,7 +31,7 @@ class CrossPointWebServer {
// Used by POST upload handler
struct UploadState {
FsFile file;
HalFile file;
String fileName;
String path = "/";
size_t size = 0;
@@ -117,7 +117,7 @@ class CrossPointWebServer {
// Font upload state
struct FontUploadState {
FsFile file;
HalFile file;
std::string familyName;
std::string filePath;
bool valid = false;
+1 -1
View File
@@ -179,7 +179,7 @@ HttpDownloader::DownloadError HttpDownloader::downloadToFile(const std::string&
if (Storage.exists(destPath.c_str())) {
Storage.remove(destPath.c_str());
}
FsFile file;
HalFile file;
if (!Storage.openFileForWrite("HTTP", destPath.c_str(), file)) {
LOG_ERR("HTTP", "Failed to open file for writing");
return FILE_ERROR;
+11 -11
View File
@@ -67,7 +67,7 @@ void WebDAVHandler::raw(WebServer& server, const String& uri, HTTPRaw& raw) {
_putExisted = Storage.exists(_putPath.c_str());
if (_putExisted) {
FsFile existing = Storage.open(_putPath.c_str());
HalFile existing = Storage.open(_putPath.c_str());
if (existing && existing.isDirectory()) {
existing.close();
_putOk = false;
@@ -96,7 +96,7 @@ void WebDAVHandler::raw(WebServer& server, const String& uri, HTTPRaw& raw) {
if (_putOk) {
String tempPath = _putPath + ".davtmp";
if (_putExisted) Storage.remove(_putPath.c_str());
FsFile tmp = Storage.open(tempPath.c_str());
HalFile tmp = Storage.open(tempPath.c_str());
if (tmp) {
_putOk = tmp.rename(_putPath.c_str());
tmp.close();
@@ -182,7 +182,7 @@ void WebDAVHandler::handlePropfind(WebServer& s) {
return;
}
FsFile root = Storage.open(path.c_str());
HalFile root = Storage.open(path.c_str());
if (!root) {
if (path == "/") {
// Root should always work — send minimal response
@@ -221,7 +221,7 @@ void WebDAVHandler::handlePropfind(WebServer& s) {
// If depth > 0 and it's a directory, list children
if (depth > 0) {
FsFile file = root.openNextFile();
HalFile file = root.openNextFile();
char name[500];
while (file) {
file.getName(name, sizeof(name));
@@ -311,7 +311,7 @@ void WebDAVHandler::handleGet(WebServer& s) {
return;
}
FsFile file = Storage.open(path.c_str());
HalFile file = Storage.open(path.c_str());
if (!file) {
s.send(500, "text/plain", "Failed to open file");
return;
@@ -348,7 +348,7 @@ void WebDAVHandler::handleHead(WebServer& s) {
return;
}
FsFile file = Storage.open(path.c_str());
HalFile file = Storage.open(path.c_str());
if (!file) {
s.send(500, "text/plain", "");
return;
@@ -411,7 +411,7 @@ void WebDAVHandler::handleDelete(WebServer& s) {
return;
}
FsFile file = Storage.open(path.c_str());
HalFile file = Storage.open(path.c_str());
if (!file) {
s.send(500, "text/plain", "Failed to open");
return;
@@ -419,7 +419,7 @@ void WebDAVHandler::handleDelete(WebServer& s) {
if (file.isDirectory()) {
// Check if directory is empty
FsFile entry = file.openNextFile();
HalFile entry = file.openNextFile();
if (entry) {
entry.close();
file.close();
@@ -537,7 +537,7 @@ void WebDAVHandler::handleMove(WebServer& s) {
Storage.remove(dstPath.c_str());
}
FsFile file = Storage.open(srcPath.c_str());
HalFile file = Storage.open(srcPath.c_str());
if (!file) {
s.send(500, "text/plain", "Failed to open source");
return;
@@ -583,7 +583,7 @@ void WebDAVHandler::handleCopy(WebServer& s) {
return;
}
FsFile srcFile = Storage.open(srcPath.c_str());
HalFile srcFile = Storage.open(srcPath.c_str());
if (!srcFile) {
s.send(500, "text/plain", "Failed to open source");
return;
@@ -617,7 +617,7 @@ void WebDAVHandler::handleCopy(WebServer& s) {
Storage.remove(dstPath.c_str());
}
FsFile dstFile;
HalFile dstFile;
if (!Storage.openFileForWrite("DAV", dstPath, dstFile)) {
srcFile.close();
s.send(500, "text/plain", "Failed to create destination");
+1 -1
View File
@@ -13,7 +13,7 @@ class WebDAVHandler : public RequestHandler {
private:
// PUT streaming state (raw() is called in chunks)
FsFile _putFile;
HalFile _putFile;
String _putPath;
bool _putOk = false;
bool _putExisted = false;