Class: FileOperationsManager

FileOperationsManager()

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
Author:
  • CTrace GUI Team
Source:
Example
const fileOpsManager = new FileOperationsManager(tabManager, notificationManager);
await fileOpsManager.openWorkspace();

Classes

FileOperationsManager

Methods

formatFileSize(bytes) → {string}

Format file size for display

Parameters:
Name Type Description
bytes number

File size in bytes

Source:
Returns:
  • Formatted file size
Type
string

getCurrentWorkspacePath() → {string|null}

Get current workspace path

Source:
Returns:
  • Current workspace path
Type
string | null

getFileIcon(filename) → {string}

Get file icon based on extension

Parameters:
Name Type Description
filename string

Filename

Source:
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

Source:

(async) openFile()

Open single file

Source:

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

Source:

(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.

Source:
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

Source:

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

Source:

(async) saveAsFile()

Save file as

Source:

(async) saveFile()

Save current file

Source:

updateWorkspaceUI(folderName, fileTree)

Update workspace UI

Parameters:
Name Type Description
folderName string

Folder name

fileTree Array

File tree structure

Source: