@tauri-apps/plugin-fs 2.0.0-alpha.3 → 2.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist-js/index.cjs +724 -0
- package/dist-js/index.d.ts +591 -180
- package/dist-js/index.js +700 -0
- package/package.json +7 -11
- package/dist-js/index.min.js +0 -396
- package/dist-js/index.mjs +0 -317
package/package.json
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-fs",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"description": "Access the file system.",
|
|
5
5
|
"license": "MIT or APACHE-2.0",
|
|
6
6
|
"authors": [
|
|
7
7
|
"Tauri Programme within The Commons Conservancy"
|
|
8
8
|
],
|
|
9
9
|
"type": "module",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"types": "./dist-js/index.d.ts",
|
|
11
|
+
"main": "./dist-js/index.cjs",
|
|
12
|
+
"module": "./dist-js/index.js",
|
|
13
13
|
"exports": {
|
|
14
|
-
"import": "./dist-js/index.mjs",
|
|
15
14
|
"types": "./dist-js/index.d.ts",
|
|
16
|
-
"
|
|
15
|
+
"import": "./dist-js/index.js",
|
|
16
|
+
"require": "./dist-js/index.cjs"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist-js",
|
|
20
|
-
"!dist-js/**/*.map",
|
|
21
20
|
"README.md",
|
|
22
21
|
"LICENSE"
|
|
23
22
|
],
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"tslib": "^2.4.1"
|
|
26
|
-
},
|
|
27
23
|
"dependencies": {
|
|
28
|
-
"@tauri-apps/api": "2.0.0-alpha.
|
|
24
|
+
"@tauri-apps/api": "2.0.0-alpha.13"
|
|
29
25
|
},
|
|
30
26
|
"scripts": {
|
|
31
27
|
"build": "rollup -c"
|
package/dist-js/index.min.js
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
19
|
-
var e = new Error(message);
|
|
20
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Sends a message to the backend.
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import { invoke } from '@tauri-apps/api/primitives';
|
|
28
|
-
* await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @param cmd The command name.
|
|
32
|
-
* @param args The optional arguments to pass to the command.
|
|
33
|
-
* @param options The request options.
|
|
34
|
-
* @return A promise resolving or rejecting to the backend response.
|
|
35
|
-
*
|
|
36
|
-
* @since 1.0.0
|
|
37
|
-
*/
|
|
38
|
-
async function invoke(cmd, args = {}, options) {
|
|
39
|
-
return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
43
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
44
|
-
// SPDX-License-Identifier: MIT
|
|
45
|
-
/**
|
|
46
|
-
* The path module provides utilities for working with file and directory paths.
|
|
47
|
-
*
|
|
48
|
-
* This package is also accessible with `window.__TAURI__.path` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
|
49
|
-
*
|
|
50
|
-
* It is recommended to allowlist only the APIs you use for optimal bundle size and security.
|
|
51
|
-
* @module
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* @since 2.0.0
|
|
55
|
-
*/
|
|
56
|
-
var BaseDirectory;
|
|
57
|
-
(function (BaseDirectory) {
|
|
58
|
-
BaseDirectory[BaseDirectory["Audio"] = 1] = "Audio";
|
|
59
|
-
BaseDirectory[BaseDirectory["Cache"] = 2] = "Cache";
|
|
60
|
-
BaseDirectory[BaseDirectory["Config"] = 3] = "Config";
|
|
61
|
-
BaseDirectory[BaseDirectory["Data"] = 4] = "Data";
|
|
62
|
-
BaseDirectory[BaseDirectory["LocalData"] = 5] = "LocalData";
|
|
63
|
-
BaseDirectory[BaseDirectory["Document"] = 6] = "Document";
|
|
64
|
-
BaseDirectory[BaseDirectory["Download"] = 7] = "Download";
|
|
65
|
-
BaseDirectory[BaseDirectory["Picture"] = 8] = "Picture";
|
|
66
|
-
BaseDirectory[BaseDirectory["Public"] = 9] = "Public";
|
|
67
|
-
BaseDirectory[BaseDirectory["Video"] = 10] = "Video";
|
|
68
|
-
BaseDirectory[BaseDirectory["Resource"] = 11] = "Resource";
|
|
69
|
-
BaseDirectory[BaseDirectory["Temp"] = 12] = "Temp";
|
|
70
|
-
BaseDirectory[BaseDirectory["AppConfig"] = 13] = "AppConfig";
|
|
71
|
-
BaseDirectory[BaseDirectory["AppData"] = 14] = "AppData";
|
|
72
|
-
BaseDirectory[BaseDirectory["AppLocalData"] = 15] = "AppLocalData";
|
|
73
|
-
BaseDirectory[BaseDirectory["AppCache"] = 16] = "AppCache";
|
|
74
|
-
BaseDirectory[BaseDirectory["AppLog"] = 17] = "AppLog";
|
|
75
|
-
BaseDirectory[BaseDirectory["Desktop"] = 18] = "Desktop";
|
|
76
|
-
BaseDirectory[BaseDirectory["Executable"] = 19] = "Executable";
|
|
77
|
-
BaseDirectory[BaseDirectory["Font"] = 20] = "Font";
|
|
78
|
-
BaseDirectory[BaseDirectory["Home"] = 21] = "Home";
|
|
79
|
-
BaseDirectory[BaseDirectory["Runtime"] = 22] = "Runtime";
|
|
80
|
-
BaseDirectory[BaseDirectory["Template"] = 23] = "Template";
|
|
81
|
-
})(BaseDirectory || (BaseDirectory = {}));
|
|
82
|
-
|
|
83
|
-
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
84
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
85
|
-
// SPDX-License-Identifier: MIT
|
|
86
|
-
/**
|
|
87
|
-
* Access the file system.
|
|
88
|
-
*
|
|
89
|
-
* ## Security
|
|
90
|
-
*
|
|
91
|
-
* This module prevents path traversal, not allowing absolute paths or parent dir components
|
|
92
|
-
* (i.e. "/usr/path/to/file" or "../path/to/file" paths are not allowed).
|
|
93
|
-
* Paths accessed with this API must be relative to one of the {@link BaseDirectory | base directories}
|
|
94
|
-
* so if you need access to arbitrary filesystem paths, you must write such logic on the core layer instead.
|
|
95
|
-
*
|
|
96
|
-
* The API has a scope configuration that forces you to restrict the paths that can be accessed using glob patterns.
|
|
97
|
-
*
|
|
98
|
-
* The scope configuration is an array of glob patterns describing folder paths that are allowed.
|
|
99
|
-
* For instance, this scope configuration only allows accessing files on the
|
|
100
|
-
* *databases* folder of the {@link path.appDataDir | $APPDATA directory}:
|
|
101
|
-
* ```json
|
|
102
|
-
* {
|
|
103
|
-
* "plugins": {
|
|
104
|
-
* "fs": {
|
|
105
|
-
* "scope": ["$APPDATA/databases/*"]
|
|
106
|
-
* }
|
|
107
|
-
* }
|
|
108
|
-
* }
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* Notice the use of the `$APPDATA` variable. The value is injected at runtime, resolving to the {@link path.appDataDir | app data directory}.
|
|
112
|
-
* The available variables are:
|
|
113
|
-
* {@link path.appConfigDir | `$APPCONFIG`}, {@link path.appDataDir | `$APPDATA`}, {@link path.appLocalDataDir | `$APPLOCALDATA`},
|
|
114
|
-
* {@link path.appCacheDir | `$APPCACHE`}, {@link path.appLogDir | `$APPLOG`},
|
|
115
|
-
* {@link path.audioDir | `$AUDIO`}, {@link path.cacheDir | `$CACHE`}, {@link path.configDir | `$CONFIG`}, {@link path.dataDir | `$DATA`},
|
|
116
|
-
* {@link path.localDataDir | `$LOCALDATA`}, {@link path.desktopDir | `$DESKTOP`}, {@link path.documentDir | `$DOCUMENT`},
|
|
117
|
-
* {@link path.downloadDir | `$DOWNLOAD`}, {@link path.executableDir | `$EXE`}, {@link path.fontDir | `$FONT`}, {@link path.homeDir | `$HOME`},
|
|
118
|
-
* {@link path.pictureDir | `$PICTURE`}, {@link path.publicDir | `$PUBLIC`}, {@link path.runtimeDir | `$RUNTIME`},
|
|
119
|
-
* {@link path.templateDir | `$TEMPLATE`}, {@link path.videoDir | `$VIDEO`}, {@link path.resourceDir | `$RESOURCE`},
|
|
120
|
-
* {@link os.tempdir | `$TEMP`}.
|
|
121
|
-
*
|
|
122
|
-
* Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access.
|
|
123
|
-
*
|
|
124
|
-
* Note that this scope applies to **all** APIs on this module.
|
|
125
|
-
*
|
|
126
|
-
* @module
|
|
127
|
-
*/
|
|
128
|
-
/**
|
|
129
|
-
* Reads a file as an UTF-8 encoded string.
|
|
130
|
-
* @example
|
|
131
|
-
* ```typescript
|
|
132
|
-
* import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
133
|
-
* // Read the text file in the `$APPCONFIG/app.conf` path
|
|
134
|
-
* const contents = await readTextFile('app.conf', { dir: BaseDirectory.AppConfig });
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* @since 2.0.0
|
|
138
|
-
*/
|
|
139
|
-
async function readTextFile(filePath, options = {}) {
|
|
140
|
-
return await invoke("plugin:fs|read_text_file", {
|
|
141
|
-
path: filePath,
|
|
142
|
-
options,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Reads a file as byte array.
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* import { readBinaryFile, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
150
|
-
* // Read the image file in the `$RESOURCEDIR/avatar.png` path
|
|
151
|
-
* const contents = await readBinaryFile('avatar.png', { dir: BaseDirectory.Resource });
|
|
152
|
-
* ```
|
|
153
|
-
*
|
|
154
|
-
* @since 2.0.0
|
|
155
|
-
*/
|
|
156
|
-
async function readBinaryFile(filePath, options = {}) {
|
|
157
|
-
const arr = await invoke("plugin:fs|read_file", {
|
|
158
|
-
path: filePath,
|
|
159
|
-
options,
|
|
160
|
-
});
|
|
161
|
-
return Uint8Array.from(arr);
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Writes a UTF-8 text file.
|
|
165
|
-
*
|
|
166
|
-
* @returns A promise indicating the success or failure of the operation.
|
|
167
|
-
*
|
|
168
|
-
* @since 2.0.0
|
|
169
|
-
*/
|
|
170
|
-
async function writeTextFile(path, contents, options) {
|
|
171
|
-
if (typeof options === "object") {
|
|
172
|
-
Object.freeze(options);
|
|
173
|
-
}
|
|
174
|
-
if (typeof path === "object") {
|
|
175
|
-
Object.freeze(path);
|
|
176
|
-
}
|
|
177
|
-
const file = { path: "", contents: "" };
|
|
178
|
-
let fileOptions = options;
|
|
179
|
-
if (typeof path === "string") {
|
|
180
|
-
file.path = path;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
file.path = path.path;
|
|
184
|
-
file.contents = path.contents;
|
|
185
|
-
}
|
|
186
|
-
if (typeof contents === "string") {
|
|
187
|
-
file.contents = contents !== null && contents !== void 0 ? contents : "";
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
fileOptions = contents;
|
|
191
|
-
}
|
|
192
|
-
return await invoke("plugin:fs|write_file", {
|
|
193
|
-
path: file.path,
|
|
194
|
-
contents: Array.from(new TextEncoder().encode(file.contents)),
|
|
195
|
-
options: fileOptions,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Writes a byte array content to a file.
|
|
200
|
-
*
|
|
201
|
-
* @returns A promise indicating the success or failure of the operation.
|
|
202
|
-
*
|
|
203
|
-
* @since 2.0.0
|
|
204
|
-
*/
|
|
205
|
-
async function writeBinaryFile(path, contents, options) {
|
|
206
|
-
if (typeof options === "object") {
|
|
207
|
-
Object.freeze(options);
|
|
208
|
-
}
|
|
209
|
-
if (typeof path === "object") {
|
|
210
|
-
Object.freeze(path);
|
|
211
|
-
}
|
|
212
|
-
const file = { path: "", contents: [] };
|
|
213
|
-
let fileOptions = options;
|
|
214
|
-
if (typeof path === "string") {
|
|
215
|
-
file.path = path;
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
file.path = path.path;
|
|
219
|
-
file.contents = path.contents;
|
|
220
|
-
}
|
|
221
|
-
if (contents && "dir" in contents) {
|
|
222
|
-
fileOptions = contents;
|
|
223
|
-
}
|
|
224
|
-
else if (typeof path === "string") {
|
|
225
|
-
// @ts-expect-error in this case `contents` is always a BinaryFileContents
|
|
226
|
-
file.contents = contents !== null && contents !== void 0 ? contents : [];
|
|
227
|
-
}
|
|
228
|
-
return await invoke("plugin:fs|write_file", {
|
|
229
|
-
path: file.path,
|
|
230
|
-
contents: Array.from(file.contents instanceof ArrayBuffer
|
|
231
|
-
? new Uint8Array(file.contents)
|
|
232
|
-
: file.contents),
|
|
233
|
-
options: fileOptions,
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* List directory files.
|
|
238
|
-
* @example
|
|
239
|
-
* ```typescript
|
|
240
|
-
* import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
241
|
-
* // Reads the `$APPDATA/users` directory recursively
|
|
242
|
-
* const entries = await readDir('users', { dir: BaseDirectory.AppData, recursive: true });
|
|
243
|
-
*
|
|
244
|
-
* function processEntries(entries) {
|
|
245
|
-
* for (const entry of entries) {
|
|
246
|
-
* console.log(`Entry: ${entry.path}`);
|
|
247
|
-
* if (entry.children) {
|
|
248
|
-
* processEntries(entry.children)
|
|
249
|
-
* }
|
|
250
|
-
* }
|
|
251
|
-
* }
|
|
252
|
-
* ```
|
|
253
|
-
*
|
|
254
|
-
* @since 2.0.0
|
|
255
|
-
*/
|
|
256
|
-
async function readDir(dir, options = {}) {
|
|
257
|
-
return await invoke("plugin:fs|read_dir", {
|
|
258
|
-
path: dir,
|
|
259
|
-
options,
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Creates a directory.
|
|
264
|
-
* If one of the path's parent components doesn't exist
|
|
265
|
-
* and the `recursive` option isn't set to true, the promise will be rejected.
|
|
266
|
-
* @example
|
|
267
|
-
* ```typescript
|
|
268
|
-
* import { createDir, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
269
|
-
* // Create the `$APPDATA/users` directory
|
|
270
|
-
* await createDir('users', { dir: BaseDirectory.AppData, recursive: true });
|
|
271
|
-
* ```
|
|
272
|
-
*
|
|
273
|
-
* @returns A promise indicating the success or failure of the operation.
|
|
274
|
-
*
|
|
275
|
-
* @since 2.0.0
|
|
276
|
-
*/
|
|
277
|
-
async function createDir(dir, options = {}) {
|
|
278
|
-
return await invoke("plugin:fs|create_dir", {
|
|
279
|
-
path: dir,
|
|
280
|
-
options,
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Removes a directory.
|
|
285
|
-
* If the directory is not empty and the `recursive` option isn't set to true, the promise will be rejected.
|
|
286
|
-
* @example
|
|
287
|
-
* ```typescript
|
|
288
|
-
* import { removeDir, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
289
|
-
* // Remove the directory `$APPDATA/users`
|
|
290
|
-
* await removeDir('users', { dir: BaseDirectory.AppData });
|
|
291
|
-
* ```
|
|
292
|
-
*
|
|
293
|
-
* @returns A promise indicating the success or failure of the operation.
|
|
294
|
-
*
|
|
295
|
-
* @since 2.0.0
|
|
296
|
-
*/
|
|
297
|
-
async function removeDir(dir, options = {}) {
|
|
298
|
-
return await invoke("plugin:fs|remove_dir", {
|
|
299
|
-
path: dir,
|
|
300
|
-
options,
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Copies a file to a destination.
|
|
305
|
-
* @example
|
|
306
|
-
* ```typescript
|
|
307
|
-
* import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
308
|
-
* // Copy the `$APPCONFIG/app.conf` file to `$APPCONFIG/app.conf.bk`
|
|
309
|
-
* await copyFile('app.conf', 'app.conf.bk', { dir: BaseDirectory.AppConfig });
|
|
310
|
-
* ```
|
|
311
|
-
*
|
|
312
|
-
* @returns A promise indicating the success or failure of the operation.
|
|
313
|
-
*
|
|
314
|
-
* @since 2.0.0
|
|
315
|
-
*/
|
|
316
|
-
async function copyFile(source, destination, options = {}) {
|
|
317
|
-
return await invoke("plugin:fs|copy_file", {
|
|
318
|
-
source,
|
|
319
|
-
destination,
|
|
320
|
-
options,
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Removes a file.
|
|
325
|
-
* @example
|
|
326
|
-
* ```typescript
|
|
327
|
-
* import { removeFile, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
328
|
-
* // Remove the `$APPConfig/app.conf` file
|
|
329
|
-
* await removeFile('app.conf', { dir: BaseDirectory.AppConfig });
|
|
330
|
-
* ```
|
|
331
|
-
*
|
|
332
|
-
* @returns A promise indicating the success or failure of the operation.
|
|
333
|
-
*
|
|
334
|
-
* @since 2.0.0
|
|
335
|
-
*/
|
|
336
|
-
async function removeFile(file, options = {}) {
|
|
337
|
-
return await invoke("plugin:fs|remove_file", {
|
|
338
|
-
path: file,
|
|
339
|
-
options,
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Renames a file.
|
|
344
|
-
* @example
|
|
345
|
-
* ```typescript
|
|
346
|
-
* import { renameFile, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
347
|
-
* // Rename the `$APPDATA/avatar.png` file
|
|
348
|
-
* await renameFile('avatar.png', 'deleted.png', { dir: BaseDirectory.AppData });
|
|
349
|
-
* ```
|
|
350
|
-
*
|
|
351
|
-
* @returns A promise indicating the success or failure of the operation.
|
|
352
|
-
*
|
|
353
|
-
* @since 2.0.0
|
|
354
|
-
*/
|
|
355
|
-
async function renameFile(oldPath, newPath, options = {}) {
|
|
356
|
-
return await invoke("plugin:fs|rename_file", {
|
|
357
|
-
oldPath,
|
|
358
|
-
newPath,
|
|
359
|
-
options,
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Check if a path exists.
|
|
364
|
-
* @example
|
|
365
|
-
* ```typescript
|
|
366
|
-
* import { exists, BaseDirectory } from '@tauri-apps/plugin-fs';
|
|
367
|
-
* // Check if the `$APPDATA/avatar.png` file exists
|
|
368
|
-
* await exists('avatar.png', { dir: BaseDirectory.AppData });
|
|
369
|
-
* ```
|
|
370
|
-
*
|
|
371
|
-
* @since 2.0.0
|
|
372
|
-
*/
|
|
373
|
-
async function exists(path) {
|
|
374
|
-
return await invoke("plugin:fs|exists", { path });
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Returns the metadata for the given path.
|
|
378
|
-
*
|
|
379
|
-
* @since 2.0.0
|
|
380
|
-
*/
|
|
381
|
-
async function metadata(path) {
|
|
382
|
-
return await invoke("plugin:fs|metadata", {
|
|
383
|
-
path,
|
|
384
|
-
}).then((metadata) => {
|
|
385
|
-
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
|
386
|
-
return {
|
|
387
|
-
accessedAt: new Date(accessedAtMs),
|
|
388
|
-
createdAt: new Date(createdAtMs),
|
|
389
|
-
modifiedAt: new Date(modifiedAtMs),
|
|
390
|
-
...data,
|
|
391
|
-
};
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
export { BaseDirectory, BaseDirectory as Dir, copyFile, createDir, exists, metadata, readBinaryFile, readDir, readTextFile, removeDir, removeFile, renameFile, writeBinaryFile, writeTextFile as writeFile, writeTextFile };
|
|
396
|
-
//# sourceMappingURL=index.min.js.map
|