feat: filesystem and Files app support for >64 file entries, 64-bit sizes, async ops, GUI toolkit improvements to devexplorer app
This commit is contained in:
@@ -50,33 +50,41 @@ struct FileManagerVirtualEntry {
|
||||
SvgIcon icon_sm;
|
||||
};
|
||||
|
||||
// Hard backstop on entries per directory: protects the pagination loop from a
|
||||
// misbehaving driver and bounds memory. Far above any realistic directory.
|
||||
inline constexpr int FM_ENTRY_HARD_CAP = 8192;
|
||||
|
||||
struct FileManagerState {
|
||||
char current_path[256];
|
||||
FileManagerLocation history[16];
|
||||
int history_pos;
|
||||
int history_count;
|
||||
char entry_names[64][128];
|
||||
int entry_types[64];
|
||||
int entry_sizes[64];
|
||||
// Parallel per-entry arrays, dynamically grown together to entry_cap.
|
||||
// Allocated lazily via filemanager_ensure_entry_capacity().
|
||||
char (*entry_names)[128];
|
||||
int* entry_types;
|
||||
uint64_t* entry_sizes; // 64-bit: avoids overflow on files >= 2 GiB
|
||||
int entry_count;
|
||||
int entry_cap; // allocated capacity of the per-entry arrays
|
||||
int selected;
|
||||
int scroll_offset;
|
||||
bool is_dir[64];
|
||||
bool* is_dir;
|
||||
int last_click_item;
|
||||
uint64_t last_click_time;
|
||||
Scrollbar scrollbar;
|
||||
DesktopState* desktop;
|
||||
bool grid_view;
|
||||
int drive_indices[64]; // drive number or special-folder index for Computer view entries
|
||||
int drive_kinds[64]; // kernel BlockDeviceKind for FM_ENTRY_DRIVE entries (4 = USB MSC)
|
||||
int* drive_indices; // drive number or special-folder index for Computer view entries
|
||||
int* drive_kinds; // kernel BlockDeviceKind for FM_ENTRY_DRIVE entries (4 = USB MSC)
|
||||
|
||||
// Clipboard (supports multiple paths from a marquee selection)
|
||||
char clipboard_paths[64][256];
|
||||
// Clipboard (supports multiple paths from a selection), grown to clipboard_cap.
|
||||
char (*clipboard_paths)[256];
|
||||
int clipboard_cap;
|
||||
int clipboard_count;
|
||||
bool clipboard_is_cut;
|
||||
|
||||
// Multi-selection (grid view marquee selection)
|
||||
bool multi_selected[64];
|
||||
// Multi-selection (marquee selection), sized with the entry arrays.
|
||||
bool* multi_selected;
|
||||
int multi_count;
|
||||
|
||||
// Marquee drag state. Coordinates are stored in content space:
|
||||
@@ -107,11 +115,14 @@ struct FileManagerState {
|
||||
int pathbar_cursor;
|
||||
int pathbar_len;
|
||||
|
||||
// Virtual views
|
||||
// Virtual views (sized with the entry arrays)
|
||||
FileManagerVirtualViewKind virtual_view;
|
||||
FileManagerVirtualEntry virtual_entries[64];
|
||||
FileManagerVirtualEntry* virtual_entries;
|
||||
int virtual_entry_count;
|
||||
|
||||
// Background file operation (copy/move/delete) + its progress dialog.
|
||||
void* active_fileop; // FileOpJob*, non-null while an operation runs
|
||||
|
||||
// File Manager-owned dialogs
|
||||
void* delete_confirm_dialog;
|
||||
};
|
||||
@@ -204,6 +215,14 @@ int detect_file_type(const char* name, bool is_dir);
|
||||
void filemanager_build_fullpath(char* out, int out_max, const char* dir, const char* name);
|
||||
const char* path_basename(const char* path);
|
||||
|
||||
// Grow the per-entry parallel arrays to hold at least `needed` entries.
|
||||
// Returns false if allocation fails (callers should stop adding entries).
|
||||
bool filemanager_ensure_entry_capacity(FileManagerState* fm, int needed);
|
||||
// Grow the clipboard path array to hold at least `needed` paths.
|
||||
bool filemanager_ensure_clipboard_capacity(FileManagerState* fm, int needed);
|
||||
// Free all dynamically-allocated arrays (called on window close).
|
||||
void filemanager_free_arrays(FileManagerState* fm);
|
||||
|
||||
void filemanager_read_drives(FileManagerState* fm);
|
||||
void filemanager_read_dir(FileManagerState* fm);
|
||||
void filemanager_free_app_icons(FileManagerState* fm);
|
||||
@@ -227,6 +246,8 @@ void filemanager_delete_selected(FileManagerState* fm);
|
||||
|
||||
void filemanager_open_ctx_menu(FileManagerState* fm, int local_x, int local_y, int target_idx);
|
||||
void filemanager_close_ctx_menu(FileManagerState* fm);
|
||||
void props_center_dialog(DesktopState* ds, const void* owner_app_data,
|
||||
int w, int h, int* out_x, int* out_y);
|
||||
void filemanager_show_properties(FileManagerState* fm, int target_idx);
|
||||
void filemanager_show_multi_properties(FileManagerState* fm,
|
||||
const int* indices, int count);
|
||||
@@ -249,6 +270,19 @@ void filemanager_commit_pathbar(FileManagerState* fm);
|
||||
|
||||
void filemanager_open_entry(FileManagerState* fm, int idx);
|
||||
|
||||
// ---- Async file operations (copy/move/delete on a worker thread) ----
|
||||
enum FileOpKind : int {
|
||||
FILE_OP_COPY = 0,
|
||||
FILE_OP_MOVE = 1,
|
||||
FILE_OP_DELETE = 2,
|
||||
};
|
||||
|
||||
// Start a background copy/move of clipboard contents into the current dir,
|
||||
// or a background delete of the given paths, showing a progress dialog.
|
||||
// Returns true if a job was started (caller should not also do it inline).
|
||||
bool filemanager_start_paste_job(FileManagerState* fm);
|
||||
bool filemanager_start_delete_job(FileManagerState* fm, const char* const* paths, int count);
|
||||
|
||||
int filemanager_grid_row_height(FileManagerState* fm, int row, int cols);
|
||||
int filemanager_grid_row_y(FileManagerState* fm, int row, int cols);
|
||||
int filemanager_grid_content_height(FileManagerState* fm, int cols);
|
||||
|
||||
Reference in New Issue
Block a user