Interface IPath

interface IPath {
    BaseDirectory: typeof BaseDirectory;
    appCacheDir: (() => Promise<string>);
    appConfigDir: (() => Promise<string>);
    appDataDir: (() => Promise<string>);
    appLocalDataDir: (() => Promise<string>);
    appLogDir: (() => Promise<string>);
    audioDir: (() => Promise<string>);
    basename: ((path: string, ext?: string) => Promise<string>);
    cacheDir: (() => Promise<string>);
    configDir: (() => Promise<string>);
    dataDir: (() => Promise<string>);
    delimiter: (() => Promise<string>);
    desktopDir: (() => Promise<string>);
    dirname: ((path: string) => Promise<string>);
    documentDir: (() => Promise<string>);
    downloadDir: (() => Promise<string>);
    executableDir: (() => Promise<string>);
    extname: ((path: string) => Promise<string>);
    fontDir: (() => Promise<string>);
    homeDir: (() => Promise<string>);
    isAbsolute: ((path: string) => Promise<boolean>);
    join: ((...paths: string[]) => Promise<string>);
    localDataDir: (() => Promise<string>);
    normalize: ((path: string) => Promise<string>);
    pictureDir: (() => Promise<string>);
    publicDir: (() => Promise<string>);
    resolve: ((...paths: string[]) => Promise<string>);
    resolveResource: ((resourcePath: string) => Promise<string>);
    resourceDir: (() => Promise<string>);
    runtimeDir: (() => Promise<string>);
    sep: (() => Promise<string>);
    tempDir: (() => Promise<string>);
    templateDir: (() => Promise<string>);
    videoDir: (() => Promise<string>);
}

Properties

BaseDirectory: typeof BaseDirectory
appCacheDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the suggested directory for your app's cache files. Resolves to ${cacheDir}/${bundleIdentifier}, where bundleIdentifier is the value tauri.bundle.identifier is configured in tauri.conf.json.

      Returns Promise<string>

      import { appCacheDir } from '@tauri-apps/api/path';
      const appCacheDirPath = await appCacheDir();

      1.2.0

appConfigDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the suggested directory for your app's config files. Resolves to ${configDir}/${bundleIdentifier}, where bundleIdentifier is the value tauri.bundle.identifier is configured in tauri.conf.json.

      Returns Promise<string>

      import { appConfigDir } from '@tauri-apps/api/path';
      const appConfigDirPath = await appConfigDir();

      1.2.0

appDataDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the suggested directory for your app's data files. Resolves to ${dataDir}/${bundleIdentifier}, where bundleIdentifier is the value tauri.bundle.identifier is configured in tauri.conf.json.

      Returns Promise<string>

      import { appDataDir } from '@tauri-apps/api/path';
      const appDataDirPath = await appDataDir();

      1.2.0

appLocalDataDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the suggested directory for your app's local data files. Resolves to ${localDataDir}/${bundleIdentifier}, where bundleIdentifier is the value tauri.bundle.identifier is configured in tauri.conf.json.

      Returns Promise<string>

      import { appLocalDataDir } from '@tauri-apps/api/path';
      const appLocalDataDirPath = await appLocalDataDir();

      1.2.0

appLogDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the suggested directory for your app's log files.

      • Linux: Resolves to ${configDir}/${bundleIdentifier}/logs.
      • macOS: Resolves to ${homeDir}/Library/Logs/{bundleIdentifier}
      • Windows: Resolves to ${configDir}/${bundleIdentifier}/logs.

      Returns Promise<string>

      import { appLogDir } from '@tauri-apps/api/path';
      const appLogDirPath = await appLogDir();

      1.2.0

audioDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's audio directory.

      • Linux: Resolves to xdg-user-dirs' XDG_MUSIC_DIR.
      • macOS: Resolves to $HOME/Music.
      • Windows: Resolves to {FOLDERID_Music}.

      Returns Promise<string>

      import { audioDir } from '@tauri-apps/api/path';
      const audioDirPath = await audioDir();

      1.0.0

basename: ((path: string, ext?: string) => Promise<string>)

Type declaration

    • (path, ext?): Promise<string>
    • Returns the last portion of a path. Trailing directory separators are ignored.

      Parameters

      • path: string
      • Optionalext: string

        An optional file extension to be removed from the returned path.

      Returns Promise<string>

      import { basename } from '@tauri-apps/api/path';
      const base = await basename('path/to/app.conf');
      assert(base === 'app.conf');

      1.0.0

cacheDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's cache directory.

      • Linux: Resolves to $XDG_CACHE_HOME or $HOME/.cache.
      • macOS: Resolves to $HOME/Library/Caches.
      • Windows: Resolves to {FOLDERID_LocalAppData}.

      Returns Promise<string>

      import { cacheDir } from '@tauri-apps/api/path';
      const cacheDirPath = await cacheDir();

      1.0.0

configDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's config directory.

      • Linux: Resolves to $XDG_CONFIG_HOME or $HOME/.config.
      • macOS: Resolves to $HOME/Library/Application Support.
      • Windows: Resolves to {FOLDERID_RoamingAppData}.

      Returns Promise<string>

      import { configDir } from '@tauri-apps/api/path';
      const configDirPath = await configDir();

      1.0.0

dataDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's data directory.

      • Linux: Resolves to $XDG_DATA_HOME or $HOME/.local/share.
      • macOS: Resolves to $HOME/Library/Application Support.
      • Windows: Resolves to {FOLDERID_RoamingAppData}.

      Returns Promise<string>

      import { dataDir } from '@tauri-apps/api/path';
      const dataDirPath = await dataDir();

      1.0.0

delimiter: (() => Promise<string>)
desktopDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's desktop directory.

      • Linux: Resolves to xdg-user-dirs' XDG_DESKTOP_DIR.
      • macOS: Resolves to $HOME/Desktop.
      • Windows: Resolves to {FOLDERID_Desktop}.

      Returns Promise<string>

      import { desktopDir } from '@tauri-apps/api/path';
      const desktopPath = await desktopDir();

      1.0.0

dirname: ((path: string) => Promise<string>)

Type declaration

    • (path): Promise<string>
    • Returns the directory name of a path. Trailing directory separators are ignored.

      Parameters

      • path: string

      Returns Promise<string>

      import { dirname } from '@tauri-apps/api/path';
      const dir = await dirname('/path/to/somedir/');
      assert(dir === 'somedir');

      1.0.0

documentDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's document directory.

      Returns Promise<string>

      import { documentDir } from '@tauri-apps/api/path';
      const documentDirPath = await documentDir();
      • Linux: Resolves to xdg-user-dirs' XDG_DOCUMENTS_DIR.
      • macOS: Resolves to $HOME/Documents.
      • Windows: Resolves to {FOLDERID_Documents}.

      1.0.0

downloadDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's download directory.

      • Linux: Resolves to xdg-user-dirs' XDG_DOWNLOAD_DIR.
      • macOS: Resolves to $HOME/Downloads.
      • Windows: Resolves to {FOLDERID_Downloads}.

      Returns Promise<string>

      import { downloadDir } from '@tauri-apps/api/path';
      const downloadDirPath = await downloadDir();

      1.0.0

executableDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's executable directory.

      • Linux: Resolves to $XDG_BIN_HOME/../bin or $XDG_DATA_HOME/../bin or $HOME/.local/bin.
      • macOS: Not supported.
      • Windows: Not supported.

      Returns Promise<string>

      import { executableDir } from '@tauri-apps/api/path';
      const executableDirPath = await executableDir();

      1.0.0

extname: ((path: string) => Promise<string>)

Type declaration

    • (path): Promise<string>
    • Returns the extension of the path.

      Parameters

      • path: string

      Returns Promise<string>

      import { extname } from '@tauri-apps/api/path';
      const ext = await extname('/path/to/file.html');
      assert(ext === 'html');

      1.0.0

fontDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's font directory.

      • Linux: Resolves to $XDG_DATA_HOME/fonts or $HOME/.local/share/fonts.
      • macOS: Resolves to $HOME/Library/Fonts.
      • Windows: Not supported.

      Returns Promise<string>

      import { fontDir } from '@tauri-apps/api/path';
      const fontDirPath = await fontDir();

      1.0.0

homeDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's home directory.

      • Linux: Resolves to $HOME.
      • macOS: Resolves to $HOME.
      • Windows: Resolves to {FOLDERID_Profile}.

      Returns Promise<string>

      import { homeDir } from '@tauri-apps/api/path';
      const homeDirPath = await homeDir();

      1.0.0

isAbsolute: ((path: string) => Promise<boolean>)

Type declaration

    • (path): Promise<boolean>
    • Returns whether the path is absolute or not.

      Parameters

      • path: string

      Returns Promise<boolean>

      import { isAbsolute } from '@tauri-apps/api/path';
      assert(await isAbsolute('/home/tauri'));

      1.0.0

join: ((...paths: string[]) => Promise<string>)

Type declaration

    • (...paths): Promise<string>
    • Joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

      Parameters

      • Rest...paths: string[]

      Returns Promise<string>

      import { join, appDataDir } from '@tauri-apps/api/path';
      const appDataDirPath = await appDataDir();
      const path = await join(appDataDirPath, 'users', 'tauri', 'avatar.png');

      1.0.0

localDataDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's local data directory.

      • Linux: Resolves to $XDG_DATA_HOME or $HOME/.local/share.
      • macOS: Resolves to $HOME/Library/Application Support.
      • Windows: Resolves to {FOLDERID_LocalAppData}.

      Returns Promise<string>

      import { localDataDir } from '@tauri-apps/api/path';
      const localDataDirPath = await localDataDir();

      1.0.0

normalize: ((path: string) => Promise<string>)

Type declaration

    • (path): Promise<string>
    • Normalizes the given path, resolving '..' and '.' segments and resolve symbolic links.

      Parameters

      • path: string

      Returns Promise<string>

      import { normalize, appDataDir } from '@tauri-apps/api/path';
      const appDataDirPath = await appDataDir();
      const path = await normalize(`${appDataDirPath}/../users/tauri/avatar.png`);

      1.0.0

pictureDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's picture directory.

      • Linux: Resolves to xdg-user-dirs' XDG_PICTURES_DIR.
      • macOS: Resolves to $HOME/Pictures.
      • Windows: Resolves to {FOLDERID_Pictures}.

      Returns Promise<string>

      import { pictureDir } from '@tauri-apps/api/path';
      const pictureDirPath = await pictureDir();

      1.0.0

publicDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's public directory.

      • Linux: Resolves to xdg-user-dirs' XDG_PUBLICSHARE_DIR.
      • macOS: Resolves to $HOME/Public.
      • Windows: Resolves to {FOLDERID_Public}.

      Returns Promise<string>

      import { publicDir } from '@tauri-apps/api/path';
      const publicDirPath = await publicDir();

      1.0.0

resolve: ((...paths: string[]) => Promise<string>)

Type declaration

    • (...paths): Promise<string>
    • Resolves a sequence of paths or path segments into an absolute path.

      Parameters

      • Rest...paths: string[]

      Returns Promise<string>

      import { resolve, appDataDir } from '@tauri-apps/api/path';
      const appDataDirPath = await appDataDir();
      const path = await resolve(appDataDirPath, '..', 'users', 'tauri', 'avatar.png');

      1.0.0

resolveResource: ((resourcePath: string) => Promise<string>)

Type declaration

    • (resourcePath): Promise<string>
    • Resolve the path to a resource file.

      Parameters

      • resourcePath: string

        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 Promise<string>

      The full path to the resource.

      import { resolveResource } from '@tauri-apps/api/path';
      const resourcePath = await resolveResource('script.sh');

      1.0.0

resourceDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the application's resource directory. To resolve a resource path, see the [[resolveResource | resolveResource API]].

      Returns Promise<string>

      import { resourceDir } from '@tauri-apps/api/path';
      const resourceDirPath = await resourceDir();

      1.0.0

runtimeDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's runtime directory.

      • Linux: Resolves to $XDG_RUNTIME_DIR.
      • macOS: Not supported.
      • Windows: Not supported.

      Returns Promise<string>

      import { runtimeDir } from '@tauri-apps/api/path';
      const runtimeDirPath = await runtimeDir();

      1.0.0

sep: (() => Promise<string>)
tempDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns a temporary directory.

      Returns Promise<string>

      import { tempDir } from '@tauri-apps/api/path';
      const temp = await tempDir();

      2.0.0

templateDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's template directory.

      • Linux: Resolves to xdg-user-dirs' XDG_TEMPLATES_DIR.
      • macOS: Not supported.
      • Windows: Resolves to {FOLDERID_Templates}.

      Returns Promise<string>

      import { templateDir } from '@tauri-apps/api/path';
      const templateDirPath = await templateDir();

      1.0.0

videoDir: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns the path to the user's video directory.

      • Linux: Resolves to xdg-user-dirs' XDG_VIDEOS_DIR.
      • macOS: Resolves to $HOME/Movies.
      • Windows: Resolves to {FOLDERID_Videos}.

      Returns Promise<string>

      import { videoDir } from '@tauri-apps/api/path';
      const videoDirPath = await videoDir();

      1.0.0