@tauri-apps/plugin-fs 2.0.0-rc.0 → 2.0.0-rc.2

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/dist-js/index.cjs CHANGED
@@ -11,10 +11,10 @@ var core = require('@tauri-apps/api/core');
11
11
  *
12
12
  * ## Security
13
13
  *
14
- * This module prevents path traversal, not allowing absolute paths or parent dir components
15
- * (i.e. "/usr/path/to/file" or "../path/to/file" paths are not allowed).
16
- * Paths accessed with this API must be relative to one of the {@link BaseDirectory | base directories}
17
- * so if you need access to arbitrary filesystem paths, you must write such logic on the core layer instead.
14
+ * This module prevents path traversal, not allowing parent directory accessors to be used
15
+ * (i.e. "/usr/path/to/../file" or "../path/to/file" paths are not allowed).
16
+ * Paths accessed with this API must be either relative to one of the {@link BaseDirectory | base directories}
17
+ * or created with the {@link https://v2.tauri.app/reference/javascript/api/namespacepath | path API}.
18
18
  *
19
19
  * The API has a scope configuration that forces you to restrict the paths that can be accessed using glob patterns.
20
20
  *
@@ -36,7 +36,7 @@ var core = require('@tauri-apps/api/core');
36
36
  * The available variables are:
37
37
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appconfigdir | $APPCONFIG},
38
38
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir | $APPDATA},
39
- * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appLocaldatadir | $APPLOCALDATA},
39
+ * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#applocaldatadir | $APPLOCALDATA},
40
40
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appcachedir | $APPCACHE},
41
41
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#applogdir | $APPLOG},
42
42
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#audiodir | $AUDIO},
@@ -118,13 +118,13 @@ class FileHandle extends core.Resource {
118
118
  *
119
119
  * @example
120
120
  * ```typescript
121
- * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs"
121
+ * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
122
122
  * // if "$APP/foo/bar.txt" contains the text "hello world":
123
- * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App });
123
+ * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.AppConfig });
124
124
  * const buf = new Uint8Array(100);
125
125
  * const numberOfBytesRead = await file.read(buf); // 11 bytes
126
126
  * const text = new TextDecoder().decode(buf); // "hello world"
127
- * await close(file.rid);
127
+ * await file.close();
128
128
  * ```
129
129
  *
130
130
  * @since 2.0.0
@@ -154,11 +154,11 @@ class FileHandle extends core.Resource {
154
154
  *
155
155
  * @example
156
156
  * ```typescript
157
- * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
157
+ * import { open, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
158
158
  *
159
159
  * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long:
160
- * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App });
161
- * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App });
160
+ * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.AppLocalData });
161
+ * await file.write(new TextEncoder().encode("Hello world"));
162
162
  *
163
163
  * // Seek 6 bytes from the start of the file
164
164
  * console.log(await file.seek(6, SeekMode.Start)); // "6"
@@ -166,6 +166,8 @@ class FileHandle extends core.Resource {
166
166
  * console.log(await file.seek(2, SeekMode.Current)); // "8"
167
167
  * // Seek backwards 2 bytes from the end of the file
168
168
  * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2)
169
+ *
170
+ * await file.close();
169
171
  * ```
170
172
  *
171
173
  * @since 2.0.0
@@ -182,10 +184,11 @@ class FileHandle extends core.Resource {
182
184
  *
183
185
  * @example
184
186
  * ```typescript
185
- * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs';
186
- * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App });
187
- * const fileInfo = await fstat(file.rid);
187
+ * import { open, BaseDirectory } from '@tauri-apps/plugin-fs';
188
+ * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.AppLocalData });
189
+ * const fileInfo = await file.stat();
188
190
  * console.log(fileInfo.isFile); // true
191
+ * await file.close();
189
192
  * ```
190
193
  *
191
194
  * @since 2.0.0
@@ -202,19 +205,20 @@ class FileHandle extends core.Resource {
202
205
  *
203
206
  * @example
204
207
  * ```typescript
205
- * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs';
208
+ * import { open, BaseDirectory } from '@tauri-apps/plugin-fs';
206
209
  *
207
210
  * // truncate the entire file
208
- * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
209
- * await ftruncate(file.rid);
211
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData });
212
+ * await file.truncate();
210
213
  *
211
214
  * // truncate part of the file
212
- * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
213
- * await write(file.rid, new TextEncoder().encode("Hello World"));
214
- * await ftruncate(file.rid, 7);
215
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData });
216
+ * await file.write(new TextEncoder().encode("Hello World"));
217
+ * await file.truncate(7);
215
218
  * const data = new Uint8Array(32);
216
- * await read(file.rid, data);
219
+ * await file.read(data);
217
220
  * console.log(new TextDecoder().decode(data)); // Hello W
221
+ * await file.close();
218
222
  * ```
219
223
  *
220
224
  * @since 2.0.0
@@ -235,12 +239,12 @@ class FileHandle extends core.Resource {
235
239
  *
236
240
  * @example
237
241
  * ```typescript
238
- * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs';
242
+ * import { open, write, BaseDirectory } from '@tauri-apps/plugin-fs';
239
243
  * const encoder = new TextEncoder();
240
244
  * const data = encoder.encode("Hello world");
241
- * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App });
242
- * const bytesWritten = await write(file.rid, data); // 11
243
- * await close(file.rid);
245
+ * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.AppLocalData });
246
+ * const bytesWritten = await file.write(data); // 11
247
+ * await file.close();
244
248
  * ```
245
249
  *
246
250
  * @since 2.0.0
@@ -248,7 +252,7 @@ class FileHandle extends core.Resource {
248
252
  async write(data) {
249
253
  return await core.invoke("plugin:fs|write", {
250
254
  rid: this.rid,
251
- data: Array.from(data),
255
+ data,
252
256
  });
253
257
  }
254
258
  }
@@ -259,7 +263,9 @@ class FileHandle extends core.Resource {
259
263
  * @example
260
264
  * ```typescript
261
265
  * import { create, BaseDirectory } from "@tauri-apps/plugin-fs"
262
- * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.App });
266
+ * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.AppConfig });
267
+ * await file.write(new TextEncoder().encode("Hello world"));
268
+ * await file.close();
263
269
  * ```
264
270
  *
265
271
  * @since 2.0.0
@@ -283,9 +289,9 @@ async function create(path, options) {
283
289
  * @example
284
290
  * ```typescript
285
291
  * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
286
- * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.App });
292
+ * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.AppLocalData });
287
293
  * // Do work with file
288
- * await close(file.rid);
294
+ * await file.close();
289
295
  * ```
290
296
  *
291
297
  * @since 2.0.0
@@ -305,7 +311,7 @@ async function open(path, options) {
305
311
  * @example
306
312
  * ```typescript
307
313
  * import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs';
308
- * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.App, toPathBaseDir: BaseDirectory.App });
314
+ * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.AppConfig, toPathBaseDir: BaseDirectory.AppConfig });
309
315
  * ```
310
316
  *
311
317
  * @since 2.0.0
@@ -326,7 +332,7 @@ async function copyFile(fromPath, toPath, options) {
326
332
  * @example
327
333
  * ```typescript
328
334
  * import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs';
329
- * await mkdir('users', { baseDir: BaseDirectory.App });
335
+ * await mkdir('users', { baseDir: BaseDirectory.AppLocalData });
330
336
  * ```
331
337
  *
332
338
  * @since 2.0.0
@@ -347,14 +353,14 @@ async function mkdir(path, options) {
347
353
  * import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs';
348
354
  * import { join } from '@tauri-apps/api/path';
349
355
  * const dir = "users"
350
- * const entries = await readDir('users', { baseDir: BaseDirectory.App });
351
- * processEntriesRecursive(dir, entries);
352
- * async function processEntriesRecursive(parent, entries) {
356
+ * const entries = await readDir('users', { baseDir: BaseDirectory.AppLocalData });
357
+ * processEntriesRecursively(dir, entries);
358
+ * async function processEntriesRecursively(parent, entries) {
353
359
  * for (const entry of entries) {
354
360
  * console.log(`Entry: ${entry.name}`);
355
361
  * if (entry.isDirectory) {
356
362
  * const dir = await join(parent, entry.name);
357
- * processEntriesRecursive(dir, await readDir(dir, { baseDir: BaseDirectory.App }))
363
+ * processEntriesRecursively(dir, await readDir(dir, { baseDir: BaseDirectory.AppLocalData }))
358
364
  * }
359
365
  * }
360
366
  * }
@@ -399,7 +405,7 @@ async function readFile(path, options) {
399
405
  * @example
400
406
  * ```typescript
401
407
  * import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
402
- * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.App });
408
+ * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.AppConfig });
403
409
  * ```
404
410
  *
405
411
  * @since 2.0.0
@@ -418,7 +424,7 @@ async function readTextFile(path, options) {
418
424
  * @example
419
425
  * ```typescript
420
426
  * import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs';
421
- * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.App });
427
+ * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.AppConfig });
422
428
  * for await (const line of lines) {
423
429
  * console.log(line);
424
430
  * }
@@ -463,8 +469,8 @@ async function readTextFileLines(path, options) {
463
469
  * @example
464
470
  * ```typescript
465
471
  * import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';
466
- * await remove('users/file.txt', { baseDir: BaseDirectory.App });
467
- * await remove('users', { baseDir: BaseDirectory.App });
472
+ * await remove('users/file.txt', { baseDir: BaseDirectory.AppLocalData });
473
+ * await remove('users', { baseDir: BaseDirectory.AppLocalData });
468
474
  * ```
469
475
  *
470
476
  * @since 2.0.0
@@ -488,7 +494,7 @@ async function remove(path, options) {
488
494
  * @example
489
495
  * ```typescript
490
496
  * import { rename, BaseDirectory } from '@tauri-apps/plugin-fs';
491
- * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.App });
497
+ * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.AppLocalData });
492
498
  * ```
493
499
  *
494
500
  * @since 2.0.0
@@ -511,7 +517,7 @@ async function rename(oldPath, newPath, options) {
511
517
  * @example
512
518
  * ```typescript
513
519
  * import { stat, BaseDirectory } from '@tauri-apps/plugin-fs';
514
- * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.App });
520
+ * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.AppLocalData });
515
521
  * console.log(fileInfo.isFile); // true
516
522
  * ```
517
523
  *
@@ -532,7 +538,7 @@ async function stat(path, options) {
532
538
  * @example
533
539
  * ```typescript
534
540
  * import { lstat, BaseDirectory } from '@tauri-apps/plugin-fs';
535
- * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.App });
541
+ * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.AppLocalData });
536
542
  * console.log(fileInfo.isFile); // true
537
543
  * ```
538
544
  *
@@ -551,16 +557,16 @@ async function lstat(path, options) {
551
557
  *
552
558
  * @example
553
559
  * ```typescript
554
- * import { truncate, readFile, writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';
560
+ * import { truncate, readTextFile, writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
555
561
  * // truncate the entire file
556
- * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.App });
562
+ * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.AppLocalData });
557
563
  *
558
564
  * // truncate part of the file
559
- * let file = "file.txt";
560
- * await writeFile(file, new TextEncoder().encode("Hello World"), { baseDir: BaseDirectory.App });
561
- * await truncate(file, 7);
562
- * const data = await readFile(file, { baseDir: BaseDirectory.App });
563
- * console.log(new TextDecoder().decode(data)); // "Hello W"
565
+ * const filePath = "file.txt";
566
+ * await writeTextFile(filePath, "Hello World", { baseDir: BaseDirectory.AppLocalData });
567
+ * await truncate(filePath, 7, { baseDir: BaseDirectory.AppLocalData });
568
+ * const data = await readTextFile(filePath, { baseDir: BaseDirectory.AppLocalData });
569
+ * console.log(data); // "Hello W"
564
570
  * ```
565
571
  *
566
572
  * @since 2.0.0
@@ -583,7 +589,7 @@ async function truncate(path, len, options) {
583
589
  *
584
590
  * let encoder = new TextEncoder();
585
591
  * let data = encoder.encode("Hello World");
586
- * await writeFile('file.txt', data, { baseDir: BaseDirectory.App });
592
+ * await writeFile('file.txt', data, { baseDir: BaseDirectory.AppLocalData });
587
593
  * ```
588
594
  *
589
595
  * @since 2.0.0
@@ -605,7 +611,7 @@ async function writeFile(path, data, options) {
605
611
  * ```typescript
606
612
  * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
607
613
  *
608
- * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.App });
614
+ * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.AppLocalData });
609
615
  * ```
610
616
  *
611
617
  * @since 2.0.0
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * ## Security
5
5
  *
6
- * This module prevents path traversal, not allowing absolute paths or parent dir components
7
- * (i.e. "/usr/path/to/file" or "../path/to/file" paths are not allowed).
8
- * Paths accessed with this API must be relative to one of the {@link BaseDirectory | base directories}
9
- * so if you need access to arbitrary filesystem paths, you must write such logic on the core layer instead.
6
+ * This module prevents path traversal, not allowing parent directory accessors to be used
7
+ * (i.e. "/usr/path/to/../file" or "../path/to/file" paths are not allowed).
8
+ * Paths accessed with this API must be either relative to one of the {@link BaseDirectory | base directories}
9
+ * or created with the {@link https://v2.tauri.app/reference/javascript/api/namespacepath | path API}.
10
10
  *
11
11
  * The API has a scope configuration that forces you to restrict the paths that can be accessed using glob patterns.
12
12
  *
@@ -28,7 +28,7 @@
28
28
  * The available variables are:
29
29
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appconfigdir | $APPCONFIG},
30
30
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir | $APPDATA},
31
- * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appLocaldatadir | $APPLOCALDATA},
31
+ * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#applocaldatadir | $APPLOCALDATA},
32
32
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appcachedir | $APPCACHE},
33
33
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#applogdir | $APPLOG},
34
34
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#audiodir | $AUDIO},
@@ -218,13 +218,13 @@ declare class FileHandle extends Resource {
218
218
  *
219
219
  * @example
220
220
  * ```typescript
221
- * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs"
221
+ * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
222
222
  * // if "$APP/foo/bar.txt" contains the text "hello world":
223
- * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App });
223
+ * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.AppConfig });
224
224
  * const buf = new Uint8Array(100);
225
225
  * const numberOfBytesRead = await file.read(buf); // 11 bytes
226
226
  * const text = new TextDecoder().decode(buf); // "hello world"
227
- * await close(file.rid);
227
+ * await file.close();
228
228
  * ```
229
229
  *
230
230
  * @since 2.0.0
@@ -244,11 +244,11 @@ declare class FileHandle extends Resource {
244
244
  *
245
245
  * @example
246
246
  * ```typescript
247
- * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
247
+ * import { open, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
248
248
  *
249
249
  * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long:
250
- * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App });
251
- * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App });
250
+ * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.AppLocalData });
251
+ * await file.write(new TextEncoder().encode("Hello world"));
252
252
  *
253
253
  * // Seek 6 bytes from the start of the file
254
254
  * console.log(await file.seek(6, SeekMode.Start)); // "6"
@@ -256,6 +256,8 @@ declare class FileHandle extends Resource {
256
256
  * console.log(await file.seek(2, SeekMode.Current)); // "8"
257
257
  * // Seek backwards 2 bytes from the end of the file
258
258
  * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2)
259
+ *
260
+ * await file.close();
259
261
  * ```
260
262
  *
261
263
  * @since 2.0.0
@@ -266,10 +268,11 @@ declare class FileHandle extends Resource {
266
268
  *
267
269
  * @example
268
270
  * ```typescript
269
- * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs';
270
- * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App });
271
- * const fileInfo = await fstat(file.rid);
271
+ * import { open, BaseDirectory } from '@tauri-apps/plugin-fs';
272
+ * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.AppLocalData });
273
+ * const fileInfo = await file.stat();
272
274
  * console.log(fileInfo.isFile); // true
275
+ * await file.close();
273
276
  * ```
274
277
  *
275
278
  * @since 2.0.0
@@ -281,19 +284,20 @@ declare class FileHandle extends Resource {
281
284
  *
282
285
  * @example
283
286
  * ```typescript
284
- * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs';
287
+ * import { open, BaseDirectory } from '@tauri-apps/plugin-fs';
285
288
  *
286
289
  * // truncate the entire file
287
- * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
288
- * await ftruncate(file.rid);
290
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData });
291
+ * await file.truncate();
289
292
  *
290
293
  * // truncate part of the file
291
- * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
292
- * await write(file.rid, new TextEncoder().encode("Hello World"));
293
- * await ftruncate(file.rid, 7);
294
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData });
295
+ * await file.write(new TextEncoder().encode("Hello World"));
296
+ * await file.truncate(7);
294
297
  * const data = new Uint8Array(32);
295
- * await read(file.rid, data);
298
+ * await file.read(data);
296
299
  * console.log(new TextDecoder().decode(data)); // Hello W
300
+ * await file.close();
297
301
  * ```
298
302
  *
299
303
  * @since 2.0.0
@@ -309,12 +313,12 @@ declare class FileHandle extends Resource {
309
313
  *
310
314
  * @example
311
315
  * ```typescript
312
- * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs';
316
+ * import { open, write, BaseDirectory } from '@tauri-apps/plugin-fs';
313
317
  * const encoder = new TextEncoder();
314
318
  * const data = encoder.encode("Hello world");
315
- * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App });
316
- * const bytesWritten = await write(file.rid, data); // 11
317
- * await close(file.rid);
319
+ * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.AppLocalData });
320
+ * const bytesWritten = await file.write(data); // 11
321
+ * await file.close();
318
322
  * ```
319
323
  *
320
324
  * @since 2.0.0
@@ -335,7 +339,9 @@ interface CreateOptions {
335
339
  * @example
336
340
  * ```typescript
337
341
  * import { create, BaseDirectory } from "@tauri-apps/plugin-fs"
338
- * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.App });
342
+ * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.AppConfig });
343
+ * await file.write(new TextEncoder().encode("Hello world"));
344
+ * await file.close();
339
345
  * ```
340
346
  *
341
347
  * @since 2.0.0
@@ -402,9 +408,9 @@ interface OpenOptions {
402
408
  * @example
403
409
  * ```typescript
404
410
  * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
405
- * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.App });
411
+ * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.AppLocalData });
406
412
  * // Do work with file
407
- * await close(file.rid);
413
+ * await file.close();
408
414
  * ```
409
415
  *
410
416
  * @since 2.0.0
@@ -424,7 +430,7 @@ interface CopyFileOptions {
424
430
  * @example
425
431
  * ```typescript
426
432
  * import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs';
427
- * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.App, toPathBaseDir: BaseDirectory.App });
433
+ * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.AppConfig, toPathBaseDir: BaseDirectory.AppConfig });
428
434
  * ```
429
435
  *
430
436
  * @since 2.0.0
@@ -448,7 +454,7 @@ interface MkdirOptions {
448
454
  * @example
449
455
  * ```typescript
450
456
  * import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs';
451
- * await mkdir('users', { baseDir: BaseDirectory.App });
457
+ * await mkdir('users', { baseDir: BaseDirectory.AppLocalData });
452
458
  * ```
453
459
  *
454
460
  * @since 2.0.0
@@ -485,14 +491,14 @@ interface DirEntry {
485
491
  * import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs';
486
492
  * import { join } from '@tauri-apps/api/path';
487
493
  * const dir = "users"
488
- * const entries = await readDir('users', { baseDir: BaseDirectory.App });
489
- * processEntriesRecursive(dir, entries);
490
- * async function processEntriesRecursive(parent, entries) {
494
+ * const entries = await readDir('users', { baseDir: BaseDirectory.AppLocalData });
495
+ * processEntriesRecursively(dir, entries);
496
+ * async function processEntriesRecursively(parent, entries) {
491
497
  * for (const entry of entries) {
492
498
  * console.log(`Entry: ${entry.name}`);
493
499
  * if (entry.isDirectory) {
494
500
  * const dir = await join(parent, entry.name);
495
- * processEntriesRecursive(dir, await readDir(dir, { baseDir: BaseDirectory.App }))
501
+ * processEntriesRecursively(dir, await readDir(dir, { baseDir: BaseDirectory.AppLocalData }))
496
502
  * }
497
503
  * }
498
504
  * }
@@ -525,7 +531,7 @@ declare function readFile(path: string | URL, options?: ReadFileOptions): Promis
525
531
  * @example
526
532
  * ```typescript
527
533
  * import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
528
- * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.App });
534
+ * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.AppConfig });
529
535
  * ```
530
536
  *
531
537
  * @since 2.0.0
@@ -536,7 +542,7 @@ declare function readTextFile(path: string | URL, options?: ReadFileOptions): Pr
536
542
  * @example
537
543
  * ```typescript
538
544
  * import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs';
539
- * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.App });
545
+ * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.AppConfig });
540
546
  * for await (const line of lines) {
541
547
  * console.log(line);
542
548
  * }
@@ -562,8 +568,8 @@ interface RemoveOptions {
562
568
  * @example
563
569
  * ```typescript
564
570
  * import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';
565
- * await remove('users/file.txt', { baseDir: BaseDirectory.App });
566
- * await remove('users', { baseDir: BaseDirectory.App });
571
+ * await remove('users/file.txt', { baseDir: BaseDirectory.AppLocalData });
572
+ * await remove('users', { baseDir: BaseDirectory.AppLocalData });
567
573
  * ```
568
574
  *
569
575
  * @since 2.0.0
@@ -588,7 +594,7 @@ interface RenameOptions {
588
594
  * @example
589
595
  * ```typescript
590
596
  * import { rename, BaseDirectory } from '@tauri-apps/plugin-fs';
591
- * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.App });
597
+ * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.AppLocalData });
592
598
  * ```
593
599
  *
594
600
  * @since 2.0.0
@@ -608,7 +614,7 @@ interface StatOptions {
608
614
  * @example
609
615
  * ```typescript
610
616
  * import { stat, BaseDirectory } from '@tauri-apps/plugin-fs';
611
- * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.App });
617
+ * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.AppLocalData });
612
618
  * console.log(fileInfo.isFile); // true
613
619
  * ```
614
620
  *
@@ -623,7 +629,7 @@ declare function stat(path: string | URL, options?: StatOptions): Promise<FileIn
623
629
  * @example
624
630
  * ```typescript
625
631
  * import { lstat, BaseDirectory } from '@tauri-apps/plugin-fs';
626
- * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.App });
632
+ * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.AppLocalData });
627
633
  * console.log(fileInfo.isFile); // true
628
634
  * ```
629
635
  *
@@ -643,16 +649,16 @@ interface TruncateOptions {
643
649
  *
644
650
  * @example
645
651
  * ```typescript
646
- * import { truncate, readFile, writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';
652
+ * import { truncate, readTextFile, writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
647
653
  * // truncate the entire file
648
- * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.App });
654
+ * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.AppLocalData });
649
655
  *
650
656
  * // truncate part of the file
651
- * let file = "file.txt";
652
- * await writeFile(file, new TextEncoder().encode("Hello World"), { baseDir: BaseDirectory.App });
653
- * await truncate(file, 7);
654
- * const data = await readFile(file, { baseDir: BaseDirectory.App });
655
- * console.log(new TextDecoder().decode(data)); // "Hello W"
657
+ * const filePath = "file.txt";
658
+ * await writeTextFile(filePath, "Hello World", { baseDir: BaseDirectory.AppLocalData });
659
+ * await truncate(filePath, 7, { baseDir: BaseDirectory.AppLocalData });
660
+ * const data = await readTextFile(filePath, { baseDir: BaseDirectory.AppLocalData });
661
+ * console.log(data); // "Hello W"
656
662
  * ```
657
663
  *
658
664
  * @since 2.0.0
@@ -681,7 +687,7 @@ interface WriteFileOptions {
681
687
  *
682
688
  * let encoder = new TextEncoder();
683
689
  * let data = encoder.encode("Hello World");
684
- * await writeFile('file.txt', data, { baseDir: BaseDirectory.App });
690
+ * await writeFile('file.txt', data, { baseDir: BaseDirectory.AppLocalData });
685
691
  * ```
686
692
  *
687
693
  * @since 2.0.0
@@ -693,7 +699,7 @@ declare function writeFile(path: string | URL, data: Uint8Array, options?: Write
693
699
  * ```typescript
694
700
  * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
695
701
  *
696
- * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.App });
702
+ * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.AppLocalData });
697
703
  * ```
698
704
  *
699
705
  * @since 2.0.0
package/dist-js/index.js CHANGED
@@ -9,10 +9,10 @@ import { Resource, invoke, Channel } from '@tauri-apps/api/core';
9
9
  *
10
10
  * ## Security
11
11
  *
12
- * This module prevents path traversal, not allowing absolute paths or parent dir components
13
- * (i.e. "/usr/path/to/file" or "../path/to/file" paths are not allowed).
14
- * Paths accessed with this API must be relative to one of the {@link BaseDirectory | base directories}
15
- * so if you need access to arbitrary filesystem paths, you must write such logic on the core layer instead.
12
+ * This module prevents path traversal, not allowing parent directory accessors to be used
13
+ * (i.e. "/usr/path/to/../file" or "../path/to/file" paths are not allowed).
14
+ * Paths accessed with this API must be either relative to one of the {@link BaseDirectory | base directories}
15
+ * or created with the {@link https://v2.tauri.app/reference/javascript/api/namespacepath | path API}.
16
16
  *
17
17
  * The API has a scope configuration that forces you to restrict the paths that can be accessed using glob patterns.
18
18
  *
@@ -34,7 +34,7 @@ import { Resource, invoke, Channel } from '@tauri-apps/api/core';
34
34
  * The available variables are:
35
35
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appconfigdir | $APPCONFIG},
36
36
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir | $APPDATA},
37
- * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appLocaldatadir | $APPLOCALDATA},
37
+ * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#applocaldatadir | $APPLOCALDATA},
38
38
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appcachedir | $APPCACHE},
39
39
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#applogdir | $APPLOG},
40
40
  * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#audiodir | $AUDIO},
@@ -116,13 +116,13 @@ class FileHandle extends Resource {
116
116
  *
117
117
  * @example
118
118
  * ```typescript
119
- * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs"
119
+ * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
120
120
  * // if "$APP/foo/bar.txt" contains the text "hello world":
121
- * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App });
121
+ * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.AppConfig });
122
122
  * const buf = new Uint8Array(100);
123
123
  * const numberOfBytesRead = await file.read(buf); // 11 bytes
124
124
  * const text = new TextDecoder().decode(buf); // "hello world"
125
- * await close(file.rid);
125
+ * await file.close();
126
126
  * ```
127
127
  *
128
128
  * @since 2.0.0
@@ -152,11 +152,11 @@ class FileHandle extends Resource {
152
152
  *
153
153
  * @example
154
154
  * ```typescript
155
- * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
155
+ * import { open, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
156
156
  *
157
157
  * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long:
158
- * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App });
159
- * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App });
158
+ * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.AppLocalData });
159
+ * await file.write(new TextEncoder().encode("Hello world"));
160
160
  *
161
161
  * // Seek 6 bytes from the start of the file
162
162
  * console.log(await file.seek(6, SeekMode.Start)); // "6"
@@ -164,6 +164,8 @@ class FileHandle extends Resource {
164
164
  * console.log(await file.seek(2, SeekMode.Current)); // "8"
165
165
  * // Seek backwards 2 bytes from the end of the file
166
166
  * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2)
167
+ *
168
+ * await file.close();
167
169
  * ```
168
170
  *
169
171
  * @since 2.0.0
@@ -180,10 +182,11 @@ class FileHandle extends Resource {
180
182
  *
181
183
  * @example
182
184
  * ```typescript
183
- * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs';
184
- * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App });
185
- * const fileInfo = await fstat(file.rid);
185
+ * import { open, BaseDirectory } from '@tauri-apps/plugin-fs';
186
+ * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.AppLocalData });
187
+ * const fileInfo = await file.stat();
186
188
  * console.log(fileInfo.isFile); // true
189
+ * await file.close();
187
190
  * ```
188
191
  *
189
192
  * @since 2.0.0
@@ -200,19 +203,20 @@ class FileHandle extends Resource {
200
203
  *
201
204
  * @example
202
205
  * ```typescript
203
- * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs';
206
+ * import { open, BaseDirectory } from '@tauri-apps/plugin-fs';
204
207
  *
205
208
  * // truncate the entire file
206
- * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
207
- * await ftruncate(file.rid);
209
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData });
210
+ * await file.truncate();
208
211
  *
209
212
  * // truncate part of the file
210
- * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
211
- * await write(file.rid, new TextEncoder().encode("Hello World"));
212
- * await ftruncate(file.rid, 7);
213
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData });
214
+ * await file.write(new TextEncoder().encode("Hello World"));
215
+ * await file.truncate(7);
213
216
  * const data = new Uint8Array(32);
214
- * await read(file.rid, data);
217
+ * await file.read(data);
215
218
  * console.log(new TextDecoder().decode(data)); // Hello W
219
+ * await file.close();
216
220
  * ```
217
221
  *
218
222
  * @since 2.0.0
@@ -233,12 +237,12 @@ class FileHandle extends Resource {
233
237
  *
234
238
  * @example
235
239
  * ```typescript
236
- * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs';
240
+ * import { open, write, BaseDirectory } from '@tauri-apps/plugin-fs';
237
241
  * const encoder = new TextEncoder();
238
242
  * const data = encoder.encode("Hello world");
239
- * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App });
240
- * const bytesWritten = await write(file.rid, data); // 11
241
- * await close(file.rid);
243
+ * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.AppLocalData });
244
+ * const bytesWritten = await file.write(data); // 11
245
+ * await file.close();
242
246
  * ```
243
247
  *
244
248
  * @since 2.0.0
@@ -246,7 +250,7 @@ class FileHandle extends Resource {
246
250
  async write(data) {
247
251
  return await invoke("plugin:fs|write", {
248
252
  rid: this.rid,
249
- data: Array.from(data),
253
+ data,
250
254
  });
251
255
  }
252
256
  }
@@ -257,7 +261,9 @@ class FileHandle extends Resource {
257
261
  * @example
258
262
  * ```typescript
259
263
  * import { create, BaseDirectory } from "@tauri-apps/plugin-fs"
260
- * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.App });
264
+ * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.AppConfig });
265
+ * await file.write(new TextEncoder().encode("Hello world"));
266
+ * await file.close();
261
267
  * ```
262
268
  *
263
269
  * @since 2.0.0
@@ -281,9 +287,9 @@ async function create(path, options) {
281
287
  * @example
282
288
  * ```typescript
283
289
  * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
284
- * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.App });
290
+ * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.AppLocalData });
285
291
  * // Do work with file
286
- * await close(file.rid);
292
+ * await file.close();
287
293
  * ```
288
294
  *
289
295
  * @since 2.0.0
@@ -303,7 +309,7 @@ async function open(path, options) {
303
309
  * @example
304
310
  * ```typescript
305
311
  * import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs';
306
- * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.App, toPathBaseDir: BaseDirectory.App });
312
+ * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.AppConfig, toPathBaseDir: BaseDirectory.AppConfig });
307
313
  * ```
308
314
  *
309
315
  * @since 2.0.0
@@ -324,7 +330,7 @@ async function copyFile(fromPath, toPath, options) {
324
330
  * @example
325
331
  * ```typescript
326
332
  * import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs';
327
- * await mkdir('users', { baseDir: BaseDirectory.App });
333
+ * await mkdir('users', { baseDir: BaseDirectory.AppLocalData });
328
334
  * ```
329
335
  *
330
336
  * @since 2.0.0
@@ -345,14 +351,14 @@ async function mkdir(path, options) {
345
351
  * import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs';
346
352
  * import { join } from '@tauri-apps/api/path';
347
353
  * const dir = "users"
348
- * const entries = await readDir('users', { baseDir: BaseDirectory.App });
349
- * processEntriesRecursive(dir, entries);
350
- * async function processEntriesRecursive(parent, entries) {
354
+ * const entries = await readDir('users', { baseDir: BaseDirectory.AppLocalData });
355
+ * processEntriesRecursively(dir, entries);
356
+ * async function processEntriesRecursively(parent, entries) {
351
357
  * for (const entry of entries) {
352
358
  * console.log(`Entry: ${entry.name}`);
353
359
  * if (entry.isDirectory) {
354
360
  * const dir = await join(parent, entry.name);
355
- * processEntriesRecursive(dir, await readDir(dir, { baseDir: BaseDirectory.App }))
361
+ * processEntriesRecursively(dir, await readDir(dir, { baseDir: BaseDirectory.AppLocalData }))
356
362
  * }
357
363
  * }
358
364
  * }
@@ -397,7 +403,7 @@ async function readFile(path, options) {
397
403
  * @example
398
404
  * ```typescript
399
405
  * import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
400
- * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.App });
406
+ * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.AppConfig });
401
407
  * ```
402
408
  *
403
409
  * @since 2.0.0
@@ -416,7 +422,7 @@ async function readTextFile(path, options) {
416
422
  * @example
417
423
  * ```typescript
418
424
  * import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs';
419
- * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.App });
425
+ * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.AppConfig });
420
426
  * for await (const line of lines) {
421
427
  * console.log(line);
422
428
  * }
@@ -461,8 +467,8 @@ async function readTextFileLines(path, options) {
461
467
  * @example
462
468
  * ```typescript
463
469
  * import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';
464
- * await remove('users/file.txt', { baseDir: BaseDirectory.App });
465
- * await remove('users', { baseDir: BaseDirectory.App });
470
+ * await remove('users/file.txt', { baseDir: BaseDirectory.AppLocalData });
471
+ * await remove('users', { baseDir: BaseDirectory.AppLocalData });
466
472
  * ```
467
473
  *
468
474
  * @since 2.0.0
@@ -486,7 +492,7 @@ async function remove(path, options) {
486
492
  * @example
487
493
  * ```typescript
488
494
  * import { rename, BaseDirectory } from '@tauri-apps/plugin-fs';
489
- * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.App });
495
+ * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.AppLocalData });
490
496
  * ```
491
497
  *
492
498
  * @since 2.0.0
@@ -509,7 +515,7 @@ async function rename(oldPath, newPath, options) {
509
515
  * @example
510
516
  * ```typescript
511
517
  * import { stat, BaseDirectory } from '@tauri-apps/plugin-fs';
512
- * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.App });
518
+ * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.AppLocalData });
513
519
  * console.log(fileInfo.isFile); // true
514
520
  * ```
515
521
  *
@@ -530,7 +536,7 @@ async function stat(path, options) {
530
536
  * @example
531
537
  * ```typescript
532
538
  * import { lstat, BaseDirectory } from '@tauri-apps/plugin-fs';
533
- * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.App });
539
+ * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.AppLocalData });
534
540
  * console.log(fileInfo.isFile); // true
535
541
  * ```
536
542
  *
@@ -549,16 +555,16 @@ async function lstat(path, options) {
549
555
  *
550
556
  * @example
551
557
  * ```typescript
552
- * import { truncate, readFile, writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';
558
+ * import { truncate, readTextFile, writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
553
559
  * // truncate the entire file
554
- * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.App });
560
+ * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.AppLocalData });
555
561
  *
556
562
  * // truncate part of the file
557
- * let file = "file.txt";
558
- * await writeFile(file, new TextEncoder().encode("Hello World"), { baseDir: BaseDirectory.App });
559
- * await truncate(file, 7);
560
- * const data = await readFile(file, { baseDir: BaseDirectory.App });
561
- * console.log(new TextDecoder().decode(data)); // "Hello W"
563
+ * const filePath = "file.txt";
564
+ * await writeTextFile(filePath, "Hello World", { baseDir: BaseDirectory.AppLocalData });
565
+ * await truncate(filePath, 7, { baseDir: BaseDirectory.AppLocalData });
566
+ * const data = await readTextFile(filePath, { baseDir: BaseDirectory.AppLocalData });
567
+ * console.log(data); // "Hello W"
562
568
  * ```
563
569
  *
564
570
  * @since 2.0.0
@@ -581,7 +587,7 @@ async function truncate(path, len, options) {
581
587
  *
582
588
  * let encoder = new TextEncoder();
583
589
  * let data = encoder.encode("Hello World");
584
- * await writeFile('file.txt', data, { baseDir: BaseDirectory.App });
590
+ * await writeFile('file.txt', data, { baseDir: BaseDirectory.AppLocalData });
585
591
  * ```
586
592
  *
587
593
  * @since 2.0.0
@@ -603,7 +609,7 @@ async function writeFile(path, data, options) {
603
609
  * ```typescript
604
610
  * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
605
611
  *
606
- * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.App });
612
+ * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.AppLocalData });
607
613
  * ```
608
614
  *
609
615
  * @since 2.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-fs",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0-rc.2",
4
4
  "description": "Access the file system.",
5
5
  "license": "MIT or APACHE-2.0",
6
6
  "authors": [
@@ -25,6 +25,6 @@
25
25
  "LICENSE"
26
26
  ],
27
27
  "dependencies": {
28
- "@tauri-apps/api": "^2.0.0-rc.0"
28
+ "@tauri-apps/api": "^2.0.0-rc.4"
29
29
  }
30
30
  }