Skip to content

CapacitorAdapter

Official

Implementation of the vault adapter for mobile devices.

app.vault.adapter returns an instance of obsidian#CapacitorAdapter on mobile devices.

Import:

import { CapacitorAdapter } from 'obsidian';

Signature:

export class CapacitorAdapter implements DataAdapter

Implements: DataAdapter

Constructor

new CapacitorAdapter(basePath: string, fs: CapacitorAdapterFs)

Constructor.

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

Properties

PropertyTypeDescription
fsCapacitorAdapterFsReference to the Capacitor file system API.

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.
copy(normalizedPath, normalizedNewPath)Promise<void>Copies a file.
exists(normalizedPath, sensitive?)Promise<boolean>Checks if a file exists.
getFullPath(normalizedPath)stringGets the full path for a file.
getName()stringGet the name of the vault.
getNativePath(normalizedPath)stringGet the native device path for a normalized vault path.
getResourcePath(normalizedPath)stringReturns a URI for the browser engine to use, for example to embed an image.
list(normalizedPath)Promise<ListedFiles>Lists all files and folders inside a folder.
listRecursiveChild(normalizedPath, child)Promise<void>Helper function for listRecursive reads children of directory.
mkdir(normalizedPath)Promise<void>Creates a new directory.
onFileChange(normalizedPath)voidHandle a file change event for the given path.
open(normalizedPath)Promise<void>Open a file using the native device handler.
process(normalizedPath, fn, options?)Promise<string>Atomically read, modify, and save the contents of a plaintext file.
quickList(normalizedFolderPath, fileEntry)voidQuickly list files in a folder and add them to the file entry.
read(normalizedPath)Promise<string>Reads a file.
readBinary(normalizedPath)Promise<ArrayBuffer>Reads a file as a binary buffer.
reconcileFileChanged(realpath, normalizedPath, stat)voidReconciles a changed file against the in-memory file listing, updating its metadata.
reconcileFileCreation(normalizedPath, normalizedNewPath, fileEntry)Promise<void>Reconcile a file creation event between old and new paths.
remove(normalizedPath)Promise<void>Removes a file.
removeFile(normalizedPath)Promise<void>Remove a file from the internal file listing and trigger events.
rename(normalizedPath, normalizedNewPath)Promise<void>Renames a file.
rmdir(normalizedPath, recursive)Promise<void>Deletes a directory.
stat(normalizedPath)Promise<Stat | null>Retrieves file stats about a file.
stopWatch()Promise<void>Stop watching for file system changes.
testInsensitive()Promise<void>Test whether the file system is case-insensitive.
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.
update(normalizedPath)Promise<void>Update the internal file listing for the given path.
watchAndList()Promise<void>Starts watching the vault and builds the initial in-memory file listing.
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: