A utility class for sandboxed file operations within a temporary directory. Prevents path traversal and forces all operations to occur in os.tmpdir().
Static
Check if a file exists in the temporary directory.
The filename to check
A promise resolving to true if the file exists, false otherwise
const hasConfig = await File.exist('config.json'); Copy
const hasConfig = await File.exist('config.json');
Read a file's contents from the temporary directory.
The filename to read
A promise resolving to the file contents (coerced to number/bigint if applicable)
const content = await File.read('data.txt'); Copy
const content = await File.read('data.txt');
Remove a file from the temporary directory.
The filename to remove
A promise resolving when the file is deleted
await File.remove('temp-data.txt'); Copy
await File.remove('temp-data.txt');
Write content to a file in the temporary directory.
The filename to write to
The content to write
A promise resolving to the written content
await File.write('output.json', '{"status":"ok"}'); Copy
await File.write('output.json', '{"status":"ok"}');
A utility class for sandboxed file operations within a temporary directory. Prevents path traversal and forces all operations to occur in os.tmpdir().