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

PropertyTypeDescription
btimeBtimeHandler for retrieving and setting birth time (creation time) of files.
fstypeof fsReference to node fs module.
fsPromisestypeof fsPromisesReference to node fs:promises module.
ipcRenderer?ElectronIpcRendererReference to electron ipcRenderer module.
killLastAction((e: Error) => void) | nullKill last action.
pathtypeof pathReference to node path module.
resourcePathPrefixstringThe URL prefix used to build resource paths (e.g. 'file:///').
urltypeof URLReference to node URL module.
watchernullSeems to always be null and unused.
watchersDataAdapterWatchersRecordRecord of active file system watchers by path.

Methods

MethodReturnsDescription
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()stringGet the absolute path to the vault.
getFilePath(normalizedPath)stringReturns the file:// path of this file.
getFullPath(normalizedPath)stringGets the full path for a file.
getName()stringGet the name of the vault.
getResourcePath(normalizedPath)stringReturns a URI for the browser engine to use, for example to embed an image.
kill()voidKill 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)voidRemove listener on specific path.
testInsensitive()voidProbes 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.
trash(fullPath)booleanMoves a file to the OS trash via IPC (desktop only).
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: