Creates a new ScopedStorage instance.
Optionalpath: string | PathOptional base directory path for storage operations. If not provided, a temporary directory is created.
PrivatededuceConverts a string or Editor.Path to Editor.Path.
PrivatereadGeneric read method that accepts a custom read function. Ensures the file is within the storage directory before reading.
PrivateverifyVerifies that a file path is within the storage directory. Prevents directory traversal attacks and unauthorized file access.
Creates a new file in the storage directory.
The name of the file to create
The file content as a string or byte array
The full path to the created file
Reads a file as a byte array.
Path to the file (relative to storage directory or absolute)
File content as Uint8Array, or null if the file is outside the storage directory
Reads a file as a string.
Path to the file (relative to storage directory or absolute)
File content as string, or null if the file is outside the storage directory
Provides safe file system operations within a specified directory. All operations are scoped to the storage directory to prevent unauthorized file access.
Example
Example