feat: enhance long press action to delete both files and directories (#1803)

## Summary

* **What is the goal of this PR?** 
Enhance file browser long-press behavior so the delete action now works
for both files and directories.

* **What changes are included?**
Updated `FileBrowserActivity.cpp` to support for directory deletion on
long-press

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_
This commit is contained in:
WuTofu
2026-05-07 17:32:30 -05:00
committed by GitHub
parent e841c84194
commit 1e2f6e2d67
+9 -6
View File
@@ -139,17 +139,20 @@ void FileBrowserActivity::loop() {
return;
}
if (mode == Mode::Books && mappedInput.getHeldTime() >= GO_HOME_MS && !isDirectory) {
// --- LONG PRESS ACTION: DELETE FILE ---
if (mode == Mode::Books && mappedInput.getHeldTime() >= GO_HOME_MS) {
// --- LONG PRESS ACTION: DELETE FILE OR DIRECTORY ---
std::string cleanBasePath = basepath;
if (cleanBasePath.back() != '/') cleanBasePath += "/";
const std::string fullPath = cleanBasePath + entry;
auto handler = [this, fullPath](const ActivityResult& res) {
auto handler = [this, fullPath, isDirectory](const ActivityResult& res) {
if (!res.isCancelled) {
LOG_DBG("FileBrowser", "Attempting to delete: %s", fullPath.c_str());
clearFileMetadata(fullPath);
if (Storage.remove(fullPath.c_str())) {
if (!isDirectory) {
clearFileMetadata(fullPath);
}
const bool deleted = isDirectory ? Storage.removeDir(fullPath.c_str()) : Storage.remove(fullPath.c_str());
if (deleted) {
LOG_DBG("FileBrowser", "Deleted successfully");
loadFiles();
if (files.empty()) {
@@ -161,7 +164,7 @@ void FileBrowserActivity::loop() {
requestUpdate(true);
} else {
LOG_ERR("FileBrowser", "Failed to delete file: %s", fullPath.c_str());
LOG_ERR("FileBrowser", "Failed to delete: %s", fullPath.c_str());
}
} else {
LOG_DBG("FileBrowser", "Delete cancelled by user");