DataAdapter
Defined in: obsidian.d.ts:935
Work directly with files and folders inside a vault. If possible prefer using the Vault API over this.
Extends
Extended by
Properties
basePath
basePath:
string
Defined in: src/obsidian/augmentations/DataAdapter.d.ts:13
Base OS path for the vault (e.g. /home/user/vault, or C:\Users\user\documents\vault)
files
files:
DataAdapterFilesRecord
Defined in: src/obsidian/augmentations/DataAdapter.d.ts:17
Mapping of file/folder path to vault entry, includes non-MD files
Methods
append()
append(
normalizedPath
,data
,options
?):Promise
<void
>
Defined in: obsidian.d.ts:996
Add text to the end of a plaintext file.
Parameters
normalizedPath
string
path to file, use normalizePath to normalize beforehand.
data
string
the text to append.
options?
(Optional)
Returns
Promise
<void
>
copy()
copy(
normalizedPath
,normalizedNewPath
):Promise
<void
>
Defined in: obsidian.d.ts:1060
Create a copy of a file.
This will fail if there is already a file at normalizedNewPath
.
Parameters
normalizedPath
string
path to file, use normalizePath to normalize beforehand.
normalizedNewPath
string
path to file, use normalizePath to normalize beforehand.
Returns
Promise
<void
>
exists()
exists(
normalizedPath
,sensitive
?):Promise
<boolean
>
Defined in: obsidian.d.ts:948
Check if something exists at the given path.
Parameters
normalizedPath
string
path to file/folder, use normalizePath to normalize beforehand.
sensitive?
boolean
Some file systems/operating systems are case-insensitive, set to true to force a case-sensitivity check.
Returns
Promise
<boolean
>
getFullPath()
getFullPath(
normalizedPath
):string
Defined in: src/obsidian/augmentations/DataAdapter.d.ts:33
Get full path of file (OS path)
Parameters
normalizedPath
string
Path to file
Returns
string
String full path to file
getFullRealPath()
getFullRealPath(
normalizedPath
):string
Defined in: src/obsidian/augmentations/DataAdapter.d.ts:40
Get full path of file (OS path)
Parameters
normalizedPath
string
Path to file
Returns
string
String full path to file
getName()
getName():
string
Defined in: obsidian.d.ts:940
Returns
string
getResourcePath()
getResourcePath(
normalizedPath
):string
Defined in: obsidian.d.ts:1011
Returns an URI for the browser engine to use, for example to embed an image.
Parameters
normalizedPath
string
path to file/folder, use normalizePath to normalize beforehand.
Returns
string
list()
list(
normalizedPath
):Promise
<ListedFiles
>
Defined in: obsidian.d.ts:960
Retrieve a list of all files and folders inside the given folder, non-recursive.
Parameters
normalizedPath
string
path to folder, use normalizePath to normalize beforehand.
Returns
mkdir()
mkdir(
normalizedPath
):Promise
<void
>
Defined in: obsidian.d.ts:1017
Create a directory.
Parameters
normalizedPath
string
path to use for new folder, use normalizePath to normalize beforehand.
Returns
Promise
<void
>
process()
process(
normalizedPath
,fn
,options
?):Promise
<string
>
Defined in: obsidian.d.ts:1005
Atomically read, modify, and save the contents of a plaintext file.
Parameters
normalizedPath
string
path to file/folder, use normalizePath to normalize beforehand.
fn
(data
) => string
a callback function which returns the new content of the file synchronously.
options?
write options.
Returns
Promise
<string
>
string - the text value of the file that was written.
queue()
queue(
next
):Promise
<void
>
Defined in: src/obsidian/internals/PromisedQueue.d.ts:5
Parameters
next
() => void
| Promise
<void
>
Returns
Promise
<void
>
Inherited from
read()
read(
normalizedPath
):Promise
<string
>
Defined in: obsidian.d.ts:965
Parameters
normalizedPath
string
path to file, use normalizePath to normalize beforehand.
Returns
Promise
<string
>
readBinary()
readBinary(
normalizedPath
):Promise
<ArrayBuffer
>
Defined in: obsidian.d.ts:970
Parameters
normalizedPath
string
path to file, use normalizePath to normalize beforehand.
Returns
remove()
remove(
normalizedPath
):Promise
<void
>
Defined in: obsidian.d.ts:1044
Delete a file.
Parameters
normalizedPath
string
path to file, use normalizePath to normalize beforehand.
Returns
Promise
<void
>
rename()
rename(
normalizedPath
,normalizedNewPath
):Promise
<void
>
Defined in: obsidian.d.ts:1052
Rename a file or folder.
Parameters
normalizedPath
string
current path to file/folder, use normalizePath to normalize beforehand.
normalizedNewPath
string
new path to file/folder, use normalizePath to normalize beforehand.
Returns
Promise
<void
>
rmdir()
rmdir(
normalizedPath
,recursive
):Promise
<void
>
Defined in: obsidian.d.ts:1038
Remove a directory.
Parameters
normalizedPath
string
path to folder, use normalizePath to normalize beforehand.
recursive
boolean
If true
, delete folders under this folder recursively, if false
the folder needs to be empty.
Returns
Promise
<void
>
stat()
Defined in: obsidian.d.ts:954
Retrieve metadata about the given file/folder.
Parameters
normalizedPath
string
path to file/folder, use normalizePath to normalize beforehand.
Returns
trashLocal()
trashLocal(
normalizedPath
):Promise
<void
>
Defined in: obsidian.d.ts:1031
Move to local trash.
Files will be moved into the .trash
folder at the root of the vault.
Parameters
normalizedPath
string
path to file/folder, use normalizePath to normalize beforehand.
Returns
Promise
<void
>
trashSystem()
trashSystem(
normalizedPath
):Promise
<boolean
>
Defined in: obsidian.d.ts:1024
Try moving to system trash.
Parameters
normalizedPath
string
path to file/folder, use normalizePath to normalize beforehand.
Returns
Promise
<boolean
>
Returns true if succeeded. This can fail due to system trash being disabled.
write()
write(
normalizedPath
,data
,options
?):Promise
<void
>
Defined in: obsidian.d.ts:979
Write to a plaintext file. If the file exists its content will be overwritten, otherwise the file will be created.
Parameters
normalizedPath
string
path to file, use normalizePath to normalize beforehand.
data
string
new file content
options?
(Optional)
Returns
Promise
<void
>
writeBinary()
writeBinary(
normalizedPath
,data
,options
?):Promise
<void
>
Defined in: obsidian.d.ts:988
Write to a binary file. If the file exists its content will be overwritten, otherwise the file will be created.
Parameters
normalizedPath
string
path to file, use normalizePath to normalize beforehand.
data
the new file content
options?
(Optional)
Returns
Promise
<void
>