File size: 21,663 Bytes
adb87a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | import { invoke } from './core.js';
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/**
* The path module provides utilities for working with file and directory paths.
*
* This package is also accessible with `window.__TAURI__.path` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
*
* It is recommended to allowlist only the APIs you use for optimal bundle size and security.
* @module
*/
/**
* @since 2.0.0
*/
var BaseDirectory;
(function (BaseDirectory) {
/**
* @see {@link audioDir} for more information.
*/
BaseDirectory[BaseDirectory["Audio"] = 1] = "Audio";
/**
* @see {@link cacheDir} for more information.
*/
BaseDirectory[BaseDirectory["Cache"] = 2] = "Cache";
/**
* @see {@link configDir} for more information.
*/
BaseDirectory[BaseDirectory["Config"] = 3] = "Config";
/**
* @see {@link dataDir} for more information.
*/
BaseDirectory[BaseDirectory["Data"] = 4] = "Data";
/**
* @see {@link localDataDir} for more information.
*/
BaseDirectory[BaseDirectory["LocalData"] = 5] = "LocalData";
/**
* @see {@link documentDir} for more information.
*/
BaseDirectory[BaseDirectory["Document"] = 6] = "Document";
/**
* @see {@link downloadDir} for more information.
*/
BaseDirectory[BaseDirectory["Download"] = 7] = "Download";
/**
* @see {@link pictureDir} for more information.
*/
BaseDirectory[BaseDirectory["Picture"] = 8] = "Picture";
/**
* @see {@link publicDir} for more information.
*/
BaseDirectory[BaseDirectory["Public"] = 9] = "Public";
/**
* @see {@link videoDir} for more information.
*/
BaseDirectory[BaseDirectory["Video"] = 10] = "Video";
/**
* @see {@link resourceDir} for more information.
*/
BaseDirectory[BaseDirectory["Resource"] = 11] = "Resource";
/**
* @see {@link tempDir} for more information.
*/
BaseDirectory[BaseDirectory["Temp"] = 12] = "Temp";
/**
* @see {@link appConfigDir} for more information.
*/
BaseDirectory[BaseDirectory["AppConfig"] = 13] = "AppConfig";
/**
* @see {@link appDataDir} for more information.
*/
BaseDirectory[BaseDirectory["AppData"] = 14] = "AppData";
/**
* @see {@link appLocalDataDir} for more information.
*/
BaseDirectory[BaseDirectory["AppLocalData"] = 15] = "AppLocalData";
/**
* @see {@link appCacheDir} for more information.
*/
BaseDirectory[BaseDirectory["AppCache"] = 16] = "AppCache";
/**
* @see {@link appLogDir} for more information.
*/
BaseDirectory[BaseDirectory["AppLog"] = 17] = "AppLog";
/**
* @see {@link desktopDir} for more information.
*/
BaseDirectory[BaseDirectory["Desktop"] = 18] = "Desktop";
/**
* @see {@link executableDir} for more information.
*/
BaseDirectory[BaseDirectory["Executable"] = 19] = "Executable";
/**
* @see {@link fontDir} for more information.
*/
BaseDirectory[BaseDirectory["Font"] = 20] = "Font";
/**
* @see {@link homeDir} for more information.
*/
BaseDirectory[BaseDirectory["Home"] = 21] = "Home";
/**
* @see {@link runtimeDir} for more information.
*/
BaseDirectory[BaseDirectory["Runtime"] = 22] = "Runtime";
/**
* @see {@link templateDir} for more information.
*/
BaseDirectory[BaseDirectory["Template"] = 23] = "Template";
})(BaseDirectory || (BaseDirectory = {}));
/**
* Returns the path to the suggested directory for your app's config files.
* Resolves to `${configDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
* @example
* ```typescript
* import { appConfigDir } from '@tauri-apps/api/path';
* const appConfigDirPath = await appConfigDir();
* ```
*
* @since 1.2.0
*/
async function appConfigDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.AppConfig
});
}
/**
* Returns the path to the suggested directory for your app's data files.
* Resolves to `${dataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
* @example
* ```typescript
* import { appDataDir } from '@tauri-apps/api/path';
* const appDataDirPath = await appDataDir();
* ```
*
* @since 1.2.0
*/
async function appDataDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.AppData
});
}
/**
* Returns the path to the suggested directory for your app's local data files.
* Resolves to `${localDataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
* @example
* ```typescript
* import { appLocalDataDir } from '@tauri-apps/api/path';
* const appLocalDataDirPath = await appLocalDataDir();
* ```
*
* @since 1.2.0
*/
async function appLocalDataDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.AppLocalData
});
}
/**
* Returns the path to the suggested directory for your app's cache files.
* Resolves to `${cacheDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
* @example
* ```typescript
* import { appCacheDir } from '@tauri-apps/api/path';
* const appCacheDirPath = await appCacheDir();
* ```
*
* @since 1.2.0
*/
async function appCacheDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.AppCache
});
}
/**
* Returns the path to the user's audio directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_MUSIC_DIR`.
* - **macOS:** Resolves to `$HOME/Music`.
* - **Windows:** Resolves to `{FOLDERID_Music}`.
* @example
* ```typescript
* import { audioDir } from '@tauri-apps/api/path';
* const audioDirPath = await audioDir();
* ```
*
* @since 1.0.0
*/
async function audioDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Audio
});
}
/**
* Returns the path to the user's cache directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `$XDG_CACHE_HOME` or `$HOME/.cache`.
* - **macOS:** Resolves to `$HOME/Library/Caches`.
* - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
* @example
* ```typescript
* import { cacheDir } from '@tauri-apps/api/path';
* const cacheDirPath = await cacheDir();
* ```
*
* @since 1.0.0
*/
async function cacheDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Cache
});
}
/**
* Returns the path to the user's config directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `$XDG_CONFIG_HOME` or `$HOME/.config`.
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
* - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
* @example
* ```typescript
* import { configDir } from '@tauri-apps/api/path';
* const configDirPath = await configDir();
* ```
*
* @since 1.0.0
*/
async function configDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Config
});
}
/**
* Returns the path to the user's data directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`.
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
* - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
* @example
* ```typescript
* import { dataDir } from '@tauri-apps/api/path';
* const dataDirPath = await dataDir();
* ```
*
* @since 1.0.0
*/
async function dataDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Data
});
}
/**
* Returns the path to the user's desktop directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DESKTOP_DIR`.
* - **macOS:** Resolves to `$HOME/Desktop`.
* - **Windows:** Resolves to `{FOLDERID_Desktop}`.
* @example
* ```typescript
* import { desktopDir } from '@tauri-apps/api/path';
* const desktopPath = await desktopDir();
* ```
*
* @since 1.0.0
*/
async function desktopDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Desktop
});
}
/**
* Returns the path to the user's document directory.
* @example
* ```typescript
* import { documentDir } from '@tauri-apps/api/path';
* const documentDirPath = await documentDir();
* ```
*
* #### Platform-specific
*
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DOCUMENTS_DIR`.
* - **macOS:** Resolves to `$HOME/Documents`.
* - **Windows:** Resolves to `{FOLDERID_Documents}`.
*
* @since 1.0.0
*/
async function documentDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Document
});
}
/**
* Returns the path to the user's download directory.
*
* #### Platform-specific
*
* - **Linux**: Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DOWNLOAD_DIR`.
* - **macOS**: Resolves to `$HOME/Downloads`.
* - **Windows**: Resolves to `{FOLDERID_Downloads}`.
* @example
* ```typescript
* import { downloadDir } from '@tauri-apps/api/path';
* const downloadDirPath = await downloadDir();
* ```
*
* @since 1.0.0
*/
async function downloadDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Download
});
}
/**
* Returns the path to the user's executable directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `$XDG_BIN_HOME/../bin` or `$XDG_DATA_HOME/../bin` or `$HOME/.local/bin`.
* - **macOS:** Not supported.
* - **Windows:** Not supported.
* @example
* ```typescript
* import { executableDir } from '@tauri-apps/api/path';
* const executableDirPath = await executableDir();
* ```
*
* @since 1.0.0
*/
async function executableDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Executable
});
}
/**
* Returns the path to the user's font directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `$XDG_DATA_HOME/fonts` or `$HOME/.local/share/fonts`.
* - **macOS:** Resolves to `$HOME/Library/Fonts`.
* - **Windows:** Not supported.
* @example
* ```typescript
* import { fontDir } from '@tauri-apps/api/path';
* const fontDirPath = await fontDir();
* ```
*
* @since 1.0.0
*/
async function fontDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Font
});
}
/**
* Returns the path to the user's home directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `$HOME`.
* - **macOS:** Resolves to `$HOME`.
* - **Windows:** Resolves to `{FOLDERID_Profile}`.
* @example
* ```typescript
* import { homeDir } from '@tauri-apps/api/path';
* const homeDirPath = await homeDir();
* ```
*
* @since 1.0.0
*/
async function homeDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Home
});
}
/**
* Returns the path to the user's local data directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`.
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
* - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
* @example
* ```typescript
* import { localDataDir } from '@tauri-apps/api/path';
* const localDataDirPath = await localDataDir();
* ```
*
* @since 1.0.0
*/
async function localDataDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.LocalData
});
}
/**
* Returns the path to the user's picture directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_PICTURES_DIR`.
* - **macOS:** Resolves to `$HOME/Pictures`.
* - **Windows:** Resolves to `{FOLDERID_Pictures}`.
* @example
* ```typescript
* import { pictureDir } from '@tauri-apps/api/path';
* const pictureDirPath = await pictureDir();
* ```
*
* @since 1.0.0
*/
async function pictureDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Picture
});
}
/**
* Returns the path to the user's public directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_PUBLICSHARE_DIR`.
* - **macOS:** Resolves to `$HOME/Public`.
* - **Windows:** Resolves to `{FOLDERID_Public}`.
* @example
* ```typescript
* import { publicDir } from '@tauri-apps/api/path';
* const publicDirPath = await publicDir();
* ```
*
* @since 1.0.0
*/
async function publicDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Public
});
}
/**
* Returns the path to the application's resource directory.
* To resolve a resource path, see {@linkcode resolveResource}.
*
* ## Platform-specific
*
* Although we provide the exact path where this function resolves to,
* this is not a contract and things might change in the future
*
* - **Windows:** Resolves to the directory that contains the main executable.
* - **Linux:** When running in an AppImage, the `APPDIR` variable will be set to
* the mounted location of the app, and the resource dir will be `${APPDIR}/usr/lib/${exe_name}`.
* If not running in an AppImage, the path is `/usr/lib/${exe_name}`.
* When running the app from `src-tauri/target/(debug|release)/`, the path is `${exe_dir}/../lib/${exe_name}`.
* - **macOS:** Resolves to `${exe_dir}/../Resources` (inside .app).
* - **iOS:** Resolves to `${exe_dir}/assets`.
* - **Android:** Currently the resources are stored in the APK as assets so it's not a normal file system path,
* we return a special URI prefix `asset://localhost/` here that can be used with the [file system plugin](https://tauri.app/plugin/file-system/),
*
* @example
* ```typescript
* import { resourceDir } from '@tauri-apps/api/path';
* const resourceDirPath = await resourceDir();
* ```
*
* @since 1.0.0
*/
async function resourceDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Resource
});
}
/**
* Resolve the path to a resource file.
* @example
* ```typescript
* import { resolveResource } from '@tauri-apps/api/path';
* const resourcePath = await resolveResource('script.sh');
* ```
*
* @param resourcePath The path to the resource.
* Must follow the same syntax as defined in `tauri.conf.json > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`).
* @returns The full path to the resource.
*
* @since 1.0.0
*/
async function resolveResource(resourcePath) {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Resource,
path: resourcePath
});
}
/**
* Returns the path to the user's runtime directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `$XDG_RUNTIME_DIR`.
* - **macOS:** Not supported.
* - **Windows:** Not supported.
* @example
* ```typescript
* import { runtimeDir } from '@tauri-apps/api/path';
* const runtimeDirPath = await runtimeDir();
* ```
*
* @since 1.0.0
*/
async function runtimeDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Runtime
});
}
/**
* Returns the path to the user's template directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_TEMPLATES_DIR`.
* - **macOS:** Not supported.
* - **Windows:** Resolves to `{FOLDERID_Templates}`.
* @example
* ```typescript
* import { templateDir } from '@tauri-apps/api/path';
* const templateDirPath = await templateDir();
* ```
*
* @since 1.0.0
*/
async function templateDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Template
});
}
/**
* Returns the path to the user's video directory.
*
* #### Platform-specific
*
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_VIDEOS_DIR`.
* - **macOS:** Resolves to `$HOME/Movies`.
* - **Windows:** Resolves to `{FOLDERID_Videos}`.
* @example
* ```typescript
* import { videoDir } from '@tauri-apps/api/path';
* const videoDirPath = await videoDir();
* ```
*
* @since 1.0.0
*/
async function videoDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Video
});
}
/**
* Returns the path to the suggested directory for your app's log files.
*
* #### Platform-specific
*
* - **Linux:** Resolves to `${configDir}/${bundleIdentifier}/logs`.
* - **macOS:** Resolves to `${homeDir}/Library/Logs/{bundleIdentifier}`
* - **Windows:** Resolves to `${configDir}/${bundleIdentifier}/logs`.
* @example
* ```typescript
* import { appLogDir } from '@tauri-apps/api/path';
* const appLogDirPath = await appLogDir();
* ```
*
* @since 1.2.0
*/
async function appLogDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.AppLog
});
}
/**
* Returns a temporary directory.
* @example
* ```typescript
* import { tempDir } from '@tauri-apps/api/path';
* const temp = await tempDir();
* ```
*
* @since 2.0.0
*/
async function tempDir() {
return invoke('plugin:path|resolve_directory', {
directory: BaseDirectory.Temp
});
}
/**
* Returns the platform-specific path segment separator:
* - `\` on Windows
* - `/` on POSIX
*
* @since 2.0.0
*/
function sep() {
return window.__TAURI_INTERNALS__.plugins.path.sep;
}
/**
* Returns the platform-specific path segment delimiter:
* - `;` on Windows
* - `:` on POSIX
*
* @since 2.0.0
*/
function delimiter() {
return window.__TAURI_INTERNALS__.plugins.path.delimiter;
}
/**
* Resolves a sequence of `paths` or `path` segments into an absolute path.
* @example
* ```typescript
* import { resolve, appDataDir } from '@tauri-apps/api/path';
* const appDataDirPath = await appDataDir();
* const path = await resolve(appDataDirPath, '..', 'users', 'tauri', 'avatar.png');
* ```
*
* @since 1.0.0
*/
async function resolve(...paths) {
return invoke('plugin:path|resolve', { paths });
}
/**
* Normalizes the given `path`, resolving `'..'` and `'.'` segments and resolve symbolic links.
* @example
* ```typescript
* import { normalize, appDataDir } from '@tauri-apps/api/path';
* const appDataDirPath = await appDataDir();
* const path = await normalize(`${appDataDirPath}/../users/tauri/avatar.png`);
* ```
*
* @since 1.0.0
*/
async function normalize(path) {
return invoke('plugin:path|normalize', { path });
}
/**
* Joins all given `path` segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
* @example
* ```typescript
* import { join, appDataDir } from '@tauri-apps/api/path';
* const appDataDirPath = await appDataDir();
* const path = await join(appDataDirPath, 'users', 'tauri', 'avatar.png');
* ```
*
* @since 1.0.0
*/
async function join(...paths) {
return invoke('plugin:path|join', { paths });
}
/**
* Returns the parent directory of a given `path`. Trailing directory separators are ignored.
* @example
* ```typescript
* import { dirname } from '@tauri-apps/api/path';
* const dir = await dirname('/path/to/somedir/');
* assert(dir === '/path/to');
* ```
*
* @since 1.0.0
*/
async function dirname(path) {
return invoke('plugin:path|dirname', { path });
}
/**
* Returns the extension of the `path`.
* @example
* ```typescript
* import { extname } from '@tauri-apps/api/path';
* const ext = await extname('/path/to/file.html');
* assert(ext === 'html');
* ```
*
* @since 1.0.0
*/
async function extname(path) {
return invoke('plugin:path|extname', { path });
}
/**
* Returns the last portion of a `path`. Trailing directory separators are ignored.
* @example
* ```typescript
* import { basename } from '@tauri-apps/api/path';
* const base = await basename('path/to/app.conf');
* assert(base === 'app.conf');
* ```
* @param ext An optional file extension to be removed from the returned path.
*
* @since 1.0.0
*/
async function basename(path, ext) {
return invoke('plugin:path|basename', { path, ext });
}
/**
* Returns whether the path is absolute or not.
* @example
* ```typescript
* import { isAbsolute } from '@tauri-apps/api/path';
* assert(await isAbsolute('/home/tauri'));
* ```
*
* @since 1.0.0
*/
async function isAbsolute(path) {
return invoke('plugin:path|is_absolute', { path });
}
export { BaseDirectory, appCacheDir, appConfigDir, appDataDir, appLocalDataDir, appLogDir, audioDir, basename, cacheDir, configDir, dataDir, delimiter, desktopDir, dirname, documentDir, downloadDir, executableDir, extname, fontDir, homeDir, isAbsolute, join, localDataDir, normalize, pictureDir, publicDir, resolve, resolveResource, resourceDir, runtimeDir, sep, tempDir, templateDir, videoDir };
|