Skip to main content

LensStudio:FileSystem

Module

Before using anything in this namespace, make sure to import LensStudio:FileSystem and add filesystem in your plugin's module.json.

Example

// module.json
{
"main": "main.js",
"permissions": ["filesystem"]
}
// main.js
import * as fs from 'LensStudio:FileSystem';
let s = fs.readFile(new Editor.Path(import.meta.resolve('ellipsis.txt')));

Classes

ClassDescription
CopyDirOptionsUsed with "LensStudio:FileSystem".CopyDirOptions.
CreateDirOptionsUsed with "LensStudio:FileSystem".CreateDirOptions.
ReadDirOptionsUsed with "LensStudio:FileSystem".ReadDirOptions.
TempDirHelper to create temporary directory.
WatcherWatches a file or directory for changes and emits events when modifications occur.

Functions

FunctionDescription
copyDirOptions can take recursive and force. The recursive parameter controls whether to read into subdirectories. The force parameter controls whether duplicated contents will be overwritten during the copying process.
copyFileCopies a file from src to dest.
createDirCreate a directory at path.
existsChecks if a file or directory exists at path.
isDirectoryChecks whether a path is a directory.
isFileChecks whether a path is a file.
readBytesReturns the content of path as bytes.
readDirReturns an array of paths relative to the specified one.
readFileReturns the content of path.
realPathResolves a path to its canonical absolute form, following symlinks.
removeRemoves the path.
renameRenames the path.
sizeGet the size of path.
writeFileWrites a file to path given the data.