Skip to content

FileSystemAdapter

Official

Implementation of the vault adapter for desktop.

app.vault.adapter returns an instance of obsidian#FileSystemAdapter on desktop devices.

Import:

import { FileSystemAdapter } from 'obsidian';

Signature:

export class FileSystemAdapter implements DataAdapter

Implements: DataAdapter

Constructor

new FileSystemAdapter(basePath: string)

Constructor.

To get the constructor instance, use getFileSystemAdapterConstructor from obsidian-typings/implementations.

Properties

Property Type Description
btime Btime Handler for retrieving and setting birth time (creation time) of files.
fs typeof fs Reference to node fs module.
fsPromises typeof fsPromises Reference to node fs:promises module.
ipcRenderer? ElectronIpcRenderer Reference to electron ipcRenderer module.
killLastAction ((e: Error) => void) | null Kill last action.
path typeof path Reference to node path module.
url typeof URL Reference to node URL module.
watcher null Seems to always be null and unused.
watchers DataAdapterWatchersRecord Record of active file system watchers by path.

Methods

Method Returns Description
append(normalizedPath, data, options?) Promise<void> Appends data to a file.
appendBinary(normalizedPath, data, options?) Promise<void> Add data to the end of a binary file.
applyWriteOptions(normalizedPath, options) Promise<void> Apply data write options to file.
copy(normalizedPath, normalizedNewPath) Promise<void> Copies a file.
copyRecursive(sourcePath, destinationPath) Promise<void> Copy a file or directory recursively.
exists(normalizedPath, sensitive?) Promise<boolean> Checks if a file exists.
getBasePath() string Get the absolute path to the vault.
getFilePath(normalizedPath) string Returns the file:// path of this file.
getFullPath(normalizedPath) string Gets the full path for a file.
getName() string Get the name of the vault.
getResourcePath(normalizedPath) string Returns a URI for the browser engine to use, for example to embed an image.
kill() void Kill file system action due to timeout.
list(normalizedPath) Promise<ListedFiles> Lists all files and folders inside a folder.
listAll() Promise<void> Generates this.files from the file system.
listRecursiveChild(normalizedPath, child) Promise<void> Helper function for listRecursive reads children of directory.
mkdir(normalizedPath) Promise<void> Creates a new directory.
mkdir(path) Promise<void>
process(normalizedPath, fn, options?) Promise<string> Atomically read, modify, and save the contents of a plaintext file.
read(normalizedPath) Promise<string> Reads a file.
readBinary(normalizedPath) Promise<ArrayBuffer> Reads a file as a binary buffer.
readLocalFile(path) Promise<ArrayBuffer>
reconcileFileCreation(normalizedPath, normalizedNewPath, stats) Promise<void> Reconcile file creation.
reconcileFileInternal(normalizedPath, normalizedNewPath) Promise<void> Reconcile an internal file change between old and new paths.
remove(normalizedPath) Promise<void> Removes a file.
rename(normalizedPath, normalizedNewPath) Promise<void> Renames a file.
rmdir(normalizedPath, recursive) Promise<void> Deletes a directory.
startWatchPath(normalizedPath) Promise<void> Start watching a path for file system changes.
stat(normalizedPath) Promise<Stat | null> Retrieves file stats about a file.
stopWatchPath(normalizedPath) void Remove listener on specific path.
testInsensitive() void Probes the file system for case-insensitivity by writing a temporary file, updating the adapter's case-sensitivity flag.
thingsHappening() Debouncer<[], void> Debounced handler triggered when file system events occur.
trashLocal(normalizedPath) Promise<void> Move to local trash. Files will be moved into the .trash folder at the root of the vault.
trashSystem(normalizedPath) Promise<boolean> Try moving to system trash.
watchHiddenRecursive(normalizedPath) Promise<void> Watch recursively for changes.
write(normalizedPath, data, options?) Promise<void> Writes a file.
writeBinary(normalizedPath, data, options?) Promise<void> Writes a file as a binary buffer.

Links to this page: