new FileOperationsManager()
File Operations Manager - Handles all file operations via IPC communication.
This manager provides a high-level interface for file and workspace operations, including opening files/workspaces, saving files, and managing the file tree. It communicates with the main process through IPC to perform actual file system operations.
- Version:
- 1.0.0
- Source:
Example
const fileOpsManager = new FileOperationsManager(tabManager, notificationManager);
await fileOpsManager.openWorkspace();
Classes
Methods
formatFileSize(bytes) → {string}
Format file size for display
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
number | File size in bytes |
Returns:
- Formatted file size
- Type
- string
getCurrentWorkspacePath() → {string|null}
Get current workspace path
Returns:
- Current workspace path
- Type
- string | null
getFileIcon(filename) → {string}
Get file icon based on extension
Parameters:
| Name | Type | Description |
|---|---|---|
filename |
string | Filename |
Returns:
- File icon emoji
- Type
- string
(async) loadFullFile(filePath)
Load full file (for partially loaded large files)
Parameters:
| Name | Type | Description |
|---|---|---|
filePath |
string | File path |
(async) openFile()
Open single file
openFileInTab(filePath, content, fileName, fileInfo)
Open file in tab
Parameters:
| Name | Type | Description |
|---|---|---|
filePath |
string | File path |
content |
string | File content |
fileName |
string | File name |
fileInfo |
Object | File metadata |
(async) openWorkspace() → {Promise.<(Object|undefined)>}
Opens a workspace folder dialog and loads the selected folder.
This method displays a folder selection dialog to the user, and if a folder is selected, it loads the folder structure and updates the UI to display the file tree. It also starts watching the workspace for file changes.
Returns:
Result object with folder info, or undefined if canceled
- Type
- Promise.<(Object|undefined)>
Example
const result = await fileOpsManager.openWorkspace();
if (result && result.success) {
console.log('Workspace opened:', result.folderPath);
}
(async) readFileFromTree(filePath)
Read file from file tree
Parameters:
| Name | Type | Description |
|---|---|---|
filePath |
string | File path to read |
renderFileTree(tree, container, level)
Render file tree
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
tree |
Array | File tree structure |
|
container |
Element | null | Container element |
level |
number | 0 | Nesting level |
(async) saveAsFile()
Save file as
(async) saveFile()
Save current file
updateWorkspaceUI(folderName, fileTree)
Update workspace UI
Parameters:
| Name | Type | Description |
|---|---|---|
folderName |
string | Folder name |
fileTree |
Array | File tree structure |