@tauri-apps/plugin-fs 2.0.0-beta.0 → 2.0.0-beta.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/README.md CHANGED
@@ -4,7 +4,7 @@ Access the file system.
4
4
 
5
5
  ## Install
6
6
 
7
- _This plugin requires a Rust version of at least **1.70**_
7
+ _This plugin requires a Rust version of at least **1.75**_
8
8
 
9
9
  There are three general methods of installation that we can recommend.
10
10
 
package/dist-js/index.cjs CHANGED
@@ -123,7 +123,7 @@ class FileHandle extends core.Resource {
123
123
  * ```typescript
124
124
  * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs"
125
125
  * // if "$APP/foo/bar.txt" contains the text "hello world":
126
- * const file = await open("foo/bar.txt", { dir: BaseDirectory.App });
126
+ * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App });
127
127
  * const buf = new Uint8Array(100);
128
128
  * const numberOfBytesRead = await file.read(buf); // 11 bytes
129
129
  * const text = new TextDecoder().decode(buf); // "hello world"
@@ -160,8 +160,8 @@ class FileHandle extends core.Resource {
160
160
  * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
161
161
  *
162
162
  * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long:
163
- * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, dir: BaseDirectory.App });
164
- * await file.write(new TextEncoder().encode("Hello world"), { dir: BaseDirectory.App });
163
+ * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App });
164
+ * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App });
165
165
  *
166
166
  * // Seek 6 bytes from the start of the file
167
167
  * console.log(await file.seek(6, SeekMode.Start)); // "6"
@@ -186,7 +186,7 @@ class FileHandle extends core.Resource {
186
186
  * @example
187
187
  * ```typescript
188
188
  * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs';
189
- * const file = await open("file.txt", { read: true, dir: BaseDirectory.App });
189
+ * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App });
190
190
  * const fileInfo = await fstat(file.rid);
191
191
  * console.log(fileInfo.isFile); // true
192
192
  * ```
@@ -208,11 +208,11 @@ class FileHandle extends core.Resource {
208
208
  * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs';
209
209
  *
210
210
  * // truncate the entire file
211
- * const file = await open("my_file.txt", { read: true, write: true, create: true, dir: BaseDirectory.App });
211
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
212
212
  * await ftruncate(file.rid);
213
213
  *
214
214
  * // truncate part of the file
215
- * const file = await open("my_file.txt", { read: true, write: true, create: true, dir: BaseDirectory.App });
215
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
216
216
  * await write(file.rid, new TextEncoder().encode("Hello World"));
217
217
  * await ftruncate(file.rid, 7);
218
218
  * const data = new Uint8Array(32);
@@ -241,7 +241,7 @@ class FileHandle extends core.Resource {
241
241
  * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs';
242
242
  * const encoder = new TextEncoder();
243
243
  * const data = encoder.encode("Hello world");
244
- * const file = await open("bar.txt", { write: true, dir: BaseDirectory.App });
244
+ * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App });
245
245
  * const bytesWritten = await write(file.rid, data); // 11
246
246
  * await close(file.rid);
247
247
  * ```
@@ -262,7 +262,7 @@ class FileHandle extends core.Resource {
262
262
  * @example
263
263
  * ```typescript
264
264
  * import { create, BaseDirectory } from "@tauri-apps/plugin-fs"
265
- * const file = await create("foo/bar.txt", { dir: BaseDirectory.App });
265
+ * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.App });
266
266
  * ```
267
267
  *
268
268
  * @since 2.0.0
@@ -286,7 +286,7 @@ async function create(path, options) {
286
286
  * @example
287
287
  * ```typescript
288
288
  * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
289
- * const file = await open("foo/bar.txt", { read: true, write: true, dir: BaseDirectory.App });
289
+ * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.App });
290
290
  * // Do work with file
291
291
  * await close(file.rid);
292
292
  * ```
@@ -308,7 +308,7 @@ async function open(path, options) {
308
308
  * @example
309
309
  * ```typescript
310
310
  * import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs';
311
- * await copyFile('app.conf', 'app.conf.bk', { dir: BaseDirectory.App });
311
+ * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.App, toPathBaseDir: BaseDirectory.App });
312
312
  * ```
313
313
  *
314
314
  * @since 2.0.0
@@ -329,7 +329,7 @@ async function copyFile(fromPath, toPath, options) {
329
329
  * @example
330
330
  * ```typescript
331
331
  * import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs';
332
- * await mkdir('users', { dir: BaseDirectory.App });
332
+ * await mkdir('users', { baseDir: BaseDirectory.App });
333
333
  * ```
334
334
  *
335
335
  * @since 2.0.0
@@ -349,14 +349,14 @@ async function mkdir(path, options) {
349
349
  * ```typescript
350
350
  * import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs';
351
351
  * const dir = "users"
352
- * const entries = await readDir('users', { dir: BaseDirectory.App });
352
+ * const entries = await readDir('users', { baseDir: BaseDirectory.App });
353
353
  * processEntriesRecursive(dir, entries);
354
354
  * async function processEntriesRecursive(parent, entries) {
355
355
  * for (const entry of entries) {
356
356
  * console.log(`Entry: ${entry.name}`);
357
357
  * if (entry.isDirectory) {
358
358
  * const dir = parent + entry.name;
359
- * processEntriesRecursive(dir, await readDir(dir, { dir: BaseDirectory.App }))
359
+ * processEntriesRecursive(dir, await readDir(dir, { baseDir: BaseDirectory.App }))
360
360
  * }
361
361
  * }
362
362
  * }
@@ -379,7 +379,7 @@ async function readDir(path, options) {
379
379
  * @example
380
380
  * ```typescript
381
381
  * import { readFile, BaseDirectory } from '@tauri-apps/plugin-fs';
382
- * const contents = await readFile('avatar.png', { dir: BaseDirectory.Resource });
382
+ * const contents = await readFile('avatar.png', { baseDir: BaseDirectory.Resource });
383
383
  * ```
384
384
  *
385
385
  * @since 2.0.0
@@ -399,7 +399,7 @@ async function readFile(path, options) {
399
399
  * @example
400
400
  * ```typescript
401
401
  * import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
402
- * const contents = await readTextFile('app.conf', { dir: BaseDirectory.App });
402
+ * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.App });
403
403
  * ```
404
404
  *
405
405
  * @since 2.0.0
@@ -418,7 +418,7 @@ async function readTextFile(path, options) {
418
418
  * @example
419
419
  * ```typescript
420
420
  * import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs';
421
- * const lines = await readTextFileLines('app.conf', { dir: BaseDirectory.App });
421
+ * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.App });
422
422
  * for await (const line of lines) {
423
423
  * console.log(line);
424
424
  * }
@@ -463,8 +463,8 @@ async function readTextFileLines(path, options) {
463
463
  * @example
464
464
  * ```typescript
465
465
  * import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';
466
- * await remove('users/file.txt', { dir: BaseDirectory.App });
467
- * await remove('users', { dir: BaseDirectory.App });
466
+ * await remove('users/file.txt', { baseDir: BaseDirectory.App });
467
+ * await remove('users', { baseDir: BaseDirectory.App });
468
468
  * ```
469
469
  *
470
470
  * @since 2.0.0
@@ -488,7 +488,7 @@ async function remove(path, options) {
488
488
  * @example
489
489
  * ```typescript
490
490
  * import { rename, BaseDirectory } from '@tauri-apps/plugin-fs';
491
- * await rename('avatar.png', 'deleted.png', { dir: BaseDirectory.App });
491
+ * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.App });
492
492
  * ```
493
493
  *
494
494
  * @since 2.0.0
@@ -511,7 +511,7 @@ async function rename(oldPath, newPath, options) {
511
511
  * @example
512
512
  * ```typescript
513
513
  * import { stat, BaseDirectory } from '@tauri-apps/plugin-fs';
514
- * const fileInfo = await stat("hello.txt", { dir: BaseDirectory.App });
514
+ * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.App });
515
515
  * console.log(fileInfo.isFile); // true
516
516
  * ```
517
517
  *
@@ -532,7 +532,7 @@ async function stat(path, options) {
532
532
  * @example
533
533
  * ```typescript
534
534
  * import { lstat, BaseDirectory } from '@tauri-apps/plugin-fs';
535
- * const fileInfo = await lstat("hello.txt", { dir: BaseDirectory.App });
535
+ * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.App });
536
536
  * console.log(fileInfo.isFile); // true
537
537
  * ```
538
538
  *
@@ -553,13 +553,13 @@ async function lstat(path, options) {
553
553
  * ```typescript
554
554
  * import { truncate, readFile, writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';
555
555
  * // truncate the entire file
556
- * await truncate("my_file.txt", 0, { dir: BaseDirectory.App });
556
+ * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.App });
557
557
  *
558
558
  * // truncate part of the file
559
559
  * let file = "file.txt";
560
- * await writeFile(file, new TextEncoder().encode("Hello World"), { dir: BaseDirectory.App });
560
+ * await writeFile(file, new TextEncoder().encode("Hello World"), { baseDir: BaseDirectory.App });
561
561
  * await truncate(file, 7);
562
- * const data = await readFile(file, { dir: BaseDirectory.App });
562
+ * const data = await readFile(file, { baseDir: BaseDirectory.App });
563
563
  * console.log(new TextDecoder().decode(data)); // "Hello W"
564
564
  * ```
565
565
  *
@@ -583,7 +583,7 @@ async function truncate(path, len, options) {
583
583
  *
584
584
  * let encoder = new TextEncoder();
585
585
  * let data = encoder.encode("Hello World");
586
- * await writeFile('file.txt', data, { dir: BaseDirectory.App });
586
+ * await writeFile('file.txt', data, { baseDir: BaseDirectory.App });
587
587
  * ```
588
588
  *
589
589
  * @since 2.0.0
@@ -604,7 +604,7 @@ async function writeFile(path, data, options) {
604
604
  * ```typescript
605
605
  * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
606
606
  *
607
- * await writeTextFile('file.txt', "Hello world", { dir: BaseDirectory.App });
607
+ * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.App });
608
608
  * ```
609
609
  *
610
610
  * @since 2.0.0
@@ -625,7 +625,7 @@ async function writeTextFile(path, data, options) {
625
625
  * ```typescript
626
626
  * import { exists, BaseDirectory } from '@tauri-apps/plugin-fs';
627
627
  * // Check if the `$APPDATA/avatar.png` file exists
628
- * await exists('avatar.png', { dir: BaseDirectory.AppData });
628
+ * await exists('avatar.png', { baseDir: BaseDirectory.AppData });
629
629
  * ```
630
630
  *
631
631
  * @since 2.0.0
@@ -221,7 +221,7 @@ declare class FileHandle extends Resource {
221
221
  * ```typescript
222
222
  * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs"
223
223
  * // if "$APP/foo/bar.txt" contains the text "hello world":
224
- * const file = await open("foo/bar.txt", { dir: BaseDirectory.App });
224
+ * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App });
225
225
  * const buf = new Uint8Array(100);
226
226
  * const numberOfBytesRead = await file.read(buf); // 11 bytes
227
227
  * const text = new TextDecoder().decode(buf); // "hello world"
@@ -248,8 +248,8 @@ declare class FileHandle extends Resource {
248
248
  * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
249
249
  *
250
250
  * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long:
251
- * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, dir: BaseDirectory.App });
252
- * await file.write(new TextEncoder().encode("Hello world"), { dir: BaseDirectory.App });
251
+ * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App });
252
+ * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App });
253
253
  *
254
254
  * // Seek 6 bytes from the start of the file
255
255
  * console.log(await file.seek(6, SeekMode.Start)); // "6"
@@ -268,7 +268,7 @@ declare class FileHandle extends Resource {
268
268
  * @example
269
269
  * ```typescript
270
270
  * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs';
271
- * const file = await open("file.txt", { read: true, dir: BaseDirectory.App });
271
+ * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App });
272
272
  * const fileInfo = await fstat(file.rid);
273
273
  * console.log(fileInfo.isFile); // true
274
274
  * ```
@@ -285,11 +285,11 @@ declare class FileHandle extends Resource {
285
285
  * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs';
286
286
  *
287
287
  * // truncate the entire file
288
- * const file = await open("my_file.txt", { read: true, write: true, create: true, dir: BaseDirectory.App });
288
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
289
289
  * await ftruncate(file.rid);
290
290
  *
291
291
  * // truncate part of the file
292
- * const file = await open("my_file.txt", { read: true, write: true, create: true, dir: BaseDirectory.App });
292
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
293
293
  * await write(file.rid, new TextEncoder().encode("Hello World"));
294
294
  * await ftruncate(file.rid, 7);
295
295
  * const data = new Uint8Array(32);
@@ -313,7 +313,7 @@ declare class FileHandle extends Resource {
313
313
  * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs';
314
314
  * const encoder = new TextEncoder();
315
315
  * const data = encoder.encode("Hello world");
316
- * const file = await open("bar.txt", { write: true, dir: BaseDirectory.App });
316
+ * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App });
317
317
  * const bytesWritten = await write(file.rid, data); // 11
318
318
  * await close(file.rid);
319
319
  * ```
@@ -336,7 +336,7 @@ interface CreateOptions {
336
336
  * @example
337
337
  * ```typescript
338
338
  * import { create, BaseDirectory } from "@tauri-apps/plugin-fs"
339
- * const file = await create("foo/bar.txt", { dir: BaseDirectory.App });
339
+ * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.App });
340
340
  * ```
341
341
  *
342
342
  * @since 2.0.0
@@ -403,7 +403,7 @@ interface OpenOptions {
403
403
  * @example
404
404
  * ```typescript
405
405
  * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
406
- * const file = await open("foo/bar.txt", { read: true, write: true, dir: BaseDirectory.App });
406
+ * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.App });
407
407
  * // Do work with file
408
408
  * await close(file.rid);
409
409
  * ```
@@ -425,7 +425,7 @@ interface CopyFileOptions {
425
425
  * @example
426
426
  * ```typescript
427
427
  * import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs';
428
- * await copyFile('app.conf', 'app.conf.bk', { dir: BaseDirectory.App });
428
+ * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.App, toPathBaseDir: BaseDirectory.App });
429
429
  * ```
430
430
  *
431
431
  * @since 2.0.0
@@ -449,7 +449,7 @@ interface MkdirOptions {
449
449
  * @example
450
450
  * ```typescript
451
451
  * import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs';
452
- * await mkdir('users', { dir: BaseDirectory.App });
452
+ * await mkdir('users', { baseDir: BaseDirectory.App });
453
453
  * ```
454
454
  *
455
455
  * @since 2.0.0
@@ -485,14 +485,14 @@ interface DirEntry {
485
485
  * ```typescript
486
486
  * import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs';
487
487
  * const dir = "users"
488
- * const entries = await readDir('users', { dir: BaseDirectory.App });
488
+ * const entries = await readDir('users', { baseDir: BaseDirectory.App });
489
489
  * processEntriesRecursive(dir, entries);
490
490
  * async function processEntriesRecursive(parent, entries) {
491
491
  * for (const entry of entries) {
492
492
  * console.log(`Entry: ${entry.name}`);
493
493
  * if (entry.isDirectory) {
494
494
  * const dir = parent + entry.name;
495
- * processEntriesRecursive(dir, await readDir(dir, { dir: BaseDirectory.App }))
495
+ * processEntriesRecursive(dir, await readDir(dir, { baseDir: BaseDirectory.App }))
496
496
  * }
497
497
  * }
498
498
  * }
@@ -514,7 +514,7 @@ interface ReadFileOptions {
514
514
  * @example
515
515
  * ```typescript
516
516
  * import { readFile, BaseDirectory } from '@tauri-apps/plugin-fs';
517
- * const contents = await readFile('avatar.png', { dir: BaseDirectory.Resource });
517
+ * const contents = await readFile('avatar.png', { baseDir: BaseDirectory.Resource });
518
518
  * ```
519
519
  *
520
520
  * @since 2.0.0
@@ -525,7 +525,7 @@ declare function readFile(path: string | URL, options?: ReadFileOptions): Promis
525
525
  * @example
526
526
  * ```typescript
527
527
  * import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
528
- * const contents = await readTextFile('app.conf', { dir: BaseDirectory.App });
528
+ * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.App });
529
529
  * ```
530
530
  *
531
531
  * @since 2.0.0
@@ -536,7 +536,7 @@ declare function readTextFile(path: string | URL, options?: ReadFileOptions): Pr
536
536
  * @example
537
537
  * ```typescript
538
538
  * import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs';
539
- * const lines = await readTextFileLines('app.conf', { dir: BaseDirectory.App });
539
+ * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.App });
540
540
  * for await (const line of lines) {
541
541
  * console.log(line);
542
542
  * }
@@ -562,8 +562,8 @@ interface RemoveOptions {
562
562
  * @example
563
563
  * ```typescript
564
564
  * import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';
565
- * await remove('users/file.txt', { dir: BaseDirectory.App });
566
- * await remove('users', { dir: BaseDirectory.App });
565
+ * await remove('users/file.txt', { baseDir: BaseDirectory.App });
566
+ * await remove('users', { baseDir: BaseDirectory.App });
567
567
  * ```
568
568
  *
569
569
  * @since 2.0.0
@@ -588,12 +588,12 @@ interface RenameOptions {
588
588
  * @example
589
589
  * ```typescript
590
590
  * import { rename, BaseDirectory } from '@tauri-apps/plugin-fs';
591
- * await rename('avatar.png', 'deleted.png', { dir: BaseDirectory.App });
591
+ * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.App });
592
592
  * ```
593
593
  *
594
594
  * @since 2.0.0
595
595
  */
596
- declare function rename(oldPath: string | URL, newPath: string | URL, options: RenameOptions): Promise<void>;
596
+ declare function rename(oldPath: string | URL, newPath: string | URL, options?: RenameOptions): Promise<void>;
597
597
  /**
598
598
  * @since 2.0.0
599
599
  */
@@ -608,7 +608,7 @@ interface StatOptions {
608
608
  * @example
609
609
  * ```typescript
610
610
  * import { stat, BaseDirectory } from '@tauri-apps/plugin-fs';
611
- * const fileInfo = await stat("hello.txt", { dir: BaseDirectory.App });
611
+ * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.App });
612
612
  * console.log(fileInfo.isFile); // true
613
613
  * ```
614
614
  *
@@ -623,7 +623,7 @@ declare function stat(path: string | URL, options?: StatOptions): Promise<FileIn
623
623
  * @example
624
624
  * ```typescript
625
625
  * import { lstat, BaseDirectory } from '@tauri-apps/plugin-fs';
626
- * const fileInfo = await lstat("hello.txt", { dir: BaseDirectory.App });
626
+ * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.App });
627
627
  * console.log(fileInfo.isFile); // true
628
628
  * ```
629
629
  *
@@ -645,13 +645,13 @@ interface TruncateOptions {
645
645
  * ```typescript
646
646
  * import { truncate, readFile, writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';
647
647
  * // truncate the entire file
648
- * await truncate("my_file.txt", 0, { dir: BaseDirectory.App });
648
+ * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.App });
649
649
  *
650
650
  * // truncate part of the file
651
651
  * let file = "file.txt";
652
- * await writeFile(file, new TextEncoder().encode("Hello World"), { dir: BaseDirectory.App });
652
+ * await writeFile(file, new TextEncoder().encode("Hello World"), { baseDir: BaseDirectory.App });
653
653
  * await truncate(file, 7);
654
- * const data = await readFile(file, { dir: BaseDirectory.App });
654
+ * const data = await readFile(file, { baseDir: BaseDirectory.App });
655
655
  * console.log(new TextDecoder().decode(data)); // "Hello W"
656
656
  * ```
657
657
  *
@@ -681,7 +681,7 @@ interface WriteFileOptions {
681
681
  *
682
682
  * let encoder = new TextEncoder();
683
683
  * let data = encoder.encode("Hello World");
684
- * await writeFile('file.txt', data, { dir: BaseDirectory.App });
684
+ * await writeFile('file.txt', data, { baseDir: BaseDirectory.App });
685
685
  * ```
686
686
  *
687
687
  * @since 2.0.0
@@ -693,7 +693,7 @@ declare function writeFile(path: string | URL, data: Uint8Array, options?: Write
693
693
  * ```typescript
694
694
  * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
695
695
  *
696
- * await writeTextFile('file.txt', "Hello world", { dir: BaseDirectory.App });
696
+ * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.App });
697
697
  * ```
698
698
  *
699
699
  * @since 2.0.0
@@ -712,7 +712,7 @@ interface ExistsOptions {
712
712
  * ```typescript
713
713
  * import { exists, BaseDirectory } from '@tauri-apps/plugin-fs';
714
714
  * // Check if the `$APPDATA/avatar.png` file exists
715
- * await exists('avatar.png', { dir: BaseDirectory.AppData });
715
+ * await exists('avatar.png', { baseDir: BaseDirectory.AppData });
716
716
  * ```
717
717
  *
718
718
  * @since 2.0.0
@@ -792,7 +792,7 @@ type WatchEventKindModify = {
792
792
  kind: "metadata";
793
793
  mode: "any" | "access-time" | "write-time" | "permissions" | "ownership" | "extended" | "other";
794
794
  } | {
795
- kind: "name";
795
+ kind: "rename";
796
796
  mode: "any" | "to" | "from" | "both" | "other";
797
797
  } | {
798
798
  kind: "other";
package/dist-js/index.js CHANGED
@@ -121,7 +121,7 @@ class FileHandle extends Resource {
121
121
  * ```typescript
122
122
  * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs"
123
123
  * // if "$APP/foo/bar.txt" contains the text "hello world":
124
- * const file = await open("foo/bar.txt", { dir: BaseDirectory.App });
124
+ * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App });
125
125
  * const buf = new Uint8Array(100);
126
126
  * const numberOfBytesRead = await file.read(buf); // 11 bytes
127
127
  * const text = new TextDecoder().decode(buf); // "hello world"
@@ -158,8 +158,8 @@ class FileHandle extends Resource {
158
158
  * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs';
159
159
  *
160
160
  * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long:
161
- * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, dir: BaseDirectory.App });
162
- * await file.write(new TextEncoder().encode("Hello world"), { dir: BaseDirectory.App });
161
+ * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App });
162
+ * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App });
163
163
  *
164
164
  * // Seek 6 bytes from the start of the file
165
165
  * console.log(await file.seek(6, SeekMode.Start)); // "6"
@@ -184,7 +184,7 @@ class FileHandle extends Resource {
184
184
  * @example
185
185
  * ```typescript
186
186
  * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs';
187
- * const file = await open("file.txt", { read: true, dir: BaseDirectory.App });
187
+ * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App });
188
188
  * const fileInfo = await fstat(file.rid);
189
189
  * console.log(fileInfo.isFile); // true
190
190
  * ```
@@ -206,11 +206,11 @@ class FileHandle extends Resource {
206
206
  * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs';
207
207
  *
208
208
  * // truncate the entire file
209
- * const file = await open("my_file.txt", { read: true, write: true, create: true, dir: BaseDirectory.App });
209
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
210
210
  * await ftruncate(file.rid);
211
211
  *
212
212
  * // truncate part of the file
213
- * const file = await open("my_file.txt", { read: true, write: true, create: true, dir: BaseDirectory.App });
213
+ * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App });
214
214
  * await write(file.rid, new TextEncoder().encode("Hello World"));
215
215
  * await ftruncate(file.rid, 7);
216
216
  * const data = new Uint8Array(32);
@@ -239,7 +239,7 @@ class FileHandle extends Resource {
239
239
  * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs';
240
240
  * const encoder = new TextEncoder();
241
241
  * const data = encoder.encode("Hello world");
242
- * const file = await open("bar.txt", { write: true, dir: BaseDirectory.App });
242
+ * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App });
243
243
  * const bytesWritten = await write(file.rid, data); // 11
244
244
  * await close(file.rid);
245
245
  * ```
@@ -260,7 +260,7 @@ class FileHandle extends Resource {
260
260
  * @example
261
261
  * ```typescript
262
262
  * import { create, BaseDirectory } from "@tauri-apps/plugin-fs"
263
- * const file = await create("foo/bar.txt", { dir: BaseDirectory.App });
263
+ * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.App });
264
264
  * ```
265
265
  *
266
266
  * @since 2.0.0
@@ -284,7 +284,7 @@ async function create(path, options) {
284
284
  * @example
285
285
  * ```typescript
286
286
  * import { open, BaseDirectory } from "@tauri-apps/plugin-fs"
287
- * const file = await open("foo/bar.txt", { read: true, write: true, dir: BaseDirectory.App });
287
+ * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.App });
288
288
  * // Do work with file
289
289
  * await close(file.rid);
290
290
  * ```
@@ -306,7 +306,7 @@ async function open(path, options) {
306
306
  * @example
307
307
  * ```typescript
308
308
  * import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs';
309
- * await copyFile('app.conf', 'app.conf.bk', { dir: BaseDirectory.App });
309
+ * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.App, toPathBaseDir: BaseDirectory.App });
310
310
  * ```
311
311
  *
312
312
  * @since 2.0.0
@@ -327,7 +327,7 @@ async function copyFile(fromPath, toPath, options) {
327
327
  * @example
328
328
  * ```typescript
329
329
  * import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs';
330
- * await mkdir('users', { dir: BaseDirectory.App });
330
+ * await mkdir('users', { baseDir: BaseDirectory.App });
331
331
  * ```
332
332
  *
333
333
  * @since 2.0.0
@@ -347,14 +347,14 @@ async function mkdir(path, options) {
347
347
  * ```typescript
348
348
  * import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs';
349
349
  * const dir = "users"
350
- * const entries = await readDir('users', { dir: BaseDirectory.App });
350
+ * const entries = await readDir('users', { baseDir: BaseDirectory.App });
351
351
  * processEntriesRecursive(dir, entries);
352
352
  * async function processEntriesRecursive(parent, entries) {
353
353
  * for (const entry of entries) {
354
354
  * console.log(`Entry: ${entry.name}`);
355
355
  * if (entry.isDirectory) {
356
356
  * const dir = parent + entry.name;
357
- * processEntriesRecursive(dir, await readDir(dir, { dir: BaseDirectory.App }))
357
+ * processEntriesRecursive(dir, await readDir(dir, { baseDir: BaseDirectory.App }))
358
358
  * }
359
359
  * }
360
360
  * }
@@ -377,7 +377,7 @@ async function readDir(path, options) {
377
377
  * @example
378
378
  * ```typescript
379
379
  * import { readFile, BaseDirectory } from '@tauri-apps/plugin-fs';
380
- * const contents = await readFile('avatar.png', { dir: BaseDirectory.Resource });
380
+ * const contents = await readFile('avatar.png', { baseDir: BaseDirectory.Resource });
381
381
  * ```
382
382
  *
383
383
  * @since 2.0.0
@@ -397,7 +397,7 @@ async function readFile(path, options) {
397
397
  * @example
398
398
  * ```typescript
399
399
  * import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
400
- * const contents = await readTextFile('app.conf', { dir: BaseDirectory.App });
400
+ * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.App });
401
401
  * ```
402
402
  *
403
403
  * @since 2.0.0
@@ -416,7 +416,7 @@ async function readTextFile(path, options) {
416
416
  * @example
417
417
  * ```typescript
418
418
  * import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs';
419
- * const lines = await readTextFileLines('app.conf', { dir: BaseDirectory.App });
419
+ * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.App });
420
420
  * for await (const line of lines) {
421
421
  * console.log(line);
422
422
  * }
@@ -461,8 +461,8 @@ async function readTextFileLines(path, options) {
461
461
  * @example
462
462
  * ```typescript
463
463
  * import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';
464
- * await remove('users/file.txt', { dir: BaseDirectory.App });
465
- * await remove('users', { dir: BaseDirectory.App });
464
+ * await remove('users/file.txt', { baseDir: BaseDirectory.App });
465
+ * await remove('users', { baseDir: BaseDirectory.App });
466
466
  * ```
467
467
  *
468
468
  * @since 2.0.0
@@ -486,7 +486,7 @@ async function remove(path, options) {
486
486
  * @example
487
487
  * ```typescript
488
488
  * import { rename, BaseDirectory } from '@tauri-apps/plugin-fs';
489
- * await rename('avatar.png', 'deleted.png', { dir: BaseDirectory.App });
489
+ * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.App });
490
490
  * ```
491
491
  *
492
492
  * @since 2.0.0
@@ -509,7 +509,7 @@ async function rename(oldPath, newPath, options) {
509
509
  * @example
510
510
  * ```typescript
511
511
  * import { stat, BaseDirectory } from '@tauri-apps/plugin-fs';
512
- * const fileInfo = await stat("hello.txt", { dir: BaseDirectory.App });
512
+ * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.App });
513
513
  * console.log(fileInfo.isFile); // true
514
514
  * ```
515
515
  *
@@ -530,7 +530,7 @@ async function stat(path, options) {
530
530
  * @example
531
531
  * ```typescript
532
532
  * import { lstat, BaseDirectory } from '@tauri-apps/plugin-fs';
533
- * const fileInfo = await lstat("hello.txt", { dir: BaseDirectory.App });
533
+ * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.App });
534
534
  * console.log(fileInfo.isFile); // true
535
535
  * ```
536
536
  *
@@ -551,13 +551,13 @@ async function lstat(path, options) {
551
551
  * ```typescript
552
552
  * import { truncate, readFile, writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';
553
553
  * // truncate the entire file
554
- * await truncate("my_file.txt", 0, { dir: BaseDirectory.App });
554
+ * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.App });
555
555
  *
556
556
  * // truncate part of the file
557
557
  * let file = "file.txt";
558
- * await writeFile(file, new TextEncoder().encode("Hello World"), { dir: BaseDirectory.App });
558
+ * await writeFile(file, new TextEncoder().encode("Hello World"), { baseDir: BaseDirectory.App });
559
559
  * await truncate(file, 7);
560
- * const data = await readFile(file, { dir: BaseDirectory.App });
560
+ * const data = await readFile(file, { baseDir: BaseDirectory.App });
561
561
  * console.log(new TextDecoder().decode(data)); // "Hello W"
562
562
  * ```
563
563
  *
@@ -581,7 +581,7 @@ async function truncate(path, len, options) {
581
581
  *
582
582
  * let encoder = new TextEncoder();
583
583
  * let data = encoder.encode("Hello World");
584
- * await writeFile('file.txt', data, { dir: BaseDirectory.App });
584
+ * await writeFile('file.txt', data, { baseDir: BaseDirectory.App });
585
585
  * ```
586
586
  *
587
587
  * @since 2.0.0
@@ -602,7 +602,7 @@ async function writeFile(path, data, options) {
602
602
  * ```typescript
603
603
  * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';
604
604
  *
605
- * await writeTextFile('file.txt', "Hello world", { dir: BaseDirectory.App });
605
+ * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.App });
606
606
  * ```
607
607
  *
608
608
  * @since 2.0.0
@@ -623,7 +623,7 @@ async function writeTextFile(path, data, options) {
623
623
  * ```typescript
624
624
  * import { exists, BaseDirectory } from '@tauri-apps/plugin-fs';
625
625
  * // Check if the `$APPDATA/avatar.png` file exists
626
- * await exists('avatar.png', { dir: BaseDirectory.AppData });
626
+ * await exists('avatar.png', { baseDir: BaseDirectory.AppData });
627
627
  * ```
628
628
  *
629
629
  * @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-beta.0",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Access the file system.",
5
5
  "license": "MIT or APACHE-2.0",
6
6
  "authors": [
@@ -21,7 +21,7 @@
21
21
  "LICENSE"
22
22
  ],
23
23
  "dependencies": {
24
- "@tauri-apps/api": "2.0.0-beta.0"
24
+ "@tauri-apps/api": "2.0.0-beta.4"
25
25
  },
26
26
  "scripts": {
27
27
  "build": "rollup -c"