File System(ファイル・システム)
Plugin 説明内容の英語表記部分について Plugin 各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
ファイル・システムにアクセスします。
This plugin requires a Rust version of at least 1.77.2
| Platform | Level | Notes |
|---|---|---|
| windows | Apps installed via MSI or NSIS in | |
| linux | No write access to | |
| macos | No write access to | |
| android | | Access is restricted to Application folder by default |
| ios | | Access is restricted to Application folder by default |
はじめに、「fs(ファイル・システム)」プラグインをインストールしてください。
自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:
npm run tauri add fsyarn run tauri add fspnpm tauri add fsdeno task tauri add fsbun tauri add fscargo tauri add fs-
src-tauriフォルダで次のコマンドを実行して、このプラグインをCargo.toml内のプロジェクトの依存関係に追加します:cargo add tauri-plugin-fs -
追加したプラグインを初期化するために
lib.rsを修正します:src-tauri/src/lib.rs #[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() {tauri::Builder::default().plugin(tauri_plugin_fs::init()).run(tauri::generate_context!()).expect("error while running tauri application");} -
お好みの JavaScript パッケージ・マネージャーを使用して、「JavaScript Guest」バインディングをインストールします:
npm install @tauri-apps/plugin-fsyarn add @tauri-apps/plugin-fspnpm add @tauri-apps/plugin-fsdeno add npm:@tauri-apps/plugin-fsbun add @tauri-apps/plugin-fs
オーディオ、キャッシュ、ドキュメント、ダウンロード、画像、パブリック、またはビデオのディレクトリを使用する場合、アプリは外部ストレージにアクセス可能である必要があります。
gen/android/app/src/main/AndroidManifest.xml ファイルの中の manifest タグに次のアクセス権限を含めてください:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />Apple 社は、ユーザーのプライバシー保護を強化するために、アプリ開発者に API の使用に対する「承認理由」を明記することを義務付けています。
このため、必要な NSPrivacyAccessedAPICategoryFileTimestamp キーと C617.1 推奨の理由を含む PrivacyInfo.xcprivacy ファイルを src-tauri/gen/apple フォルダ内に作成してください。
承認理由 approved reasons: Apple 社の「API に対する使用承認理由」記載要求は 2024/05/01 から適用されています(参考)。その理由・背景は、上記本文内のリンク先にある Apple 社サイト(英語版)に記載されています。以下、その要訳を示します: アプリのコア機能を司る API には、開発者によるものもサードパーティ製 SDK に含まれているものも、デバイスの内部信号にアクセスしてデバイスやユーザーの識別・特定(フィンカープリンティング)に繋がる潜在的な危険性があるため、その API が必要である理由(required reasons for APIs)を確認するための措置。この理由を明示しない場合、App Store でのアプリのアップロードが拒否されます。
C617.1: API 使用理由コード番号のひとつ。 「NSPrivacyAccessedAPICategory」で規定されている API 選定理由コード。「C617.1」は、「アプリ・コンテナ、アプリ・グループ・コンテナ、またはアプリの CloudKit コンテナ内のファイルのタイムスタンプ、サイズ、その他のメタデータにアクセスする」場合に、この理由コードを宣言するものです。
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"> <dict> <key>NSPrivacyAccessedAPITypes</key> <array> <dict> <key>NSPrivacyAccessedAPIType</key> <string>NSPrivacyAccessedAPICategoryFileTimestamp</string> <key>NSPrivacyAccessedAPITypeReasons</key> <array> <string>C617.1</string> </array> </dict> </array> </dict></plist>「fs(ファイルシステム)」プラグインは JavaScript と Rust の両方で利用可能です。
import { exists, BaseDirectory } from '@tauri-apps/plugin-fs';// `"withGlobalTauri": true` を使用する場合は、// const { exists, BaseDirectory } = window.__TAURI__.fs; を使用できます
// `$APPDATA/avatar.png`ファイルが存在するかどうかを確認しますawait exists('avatar.png', { baseDir: BaseDirectory.AppData });use tauri_plugin_fs::FsExt;
#[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() { tauri::Builder::default() .plugin(tauri_plugin_fs::init()) .setup(|app| { // allowed the given directory let scope = app.fs_scope(); scope.allow_directory("/path/to/directory", false); dbg!(scope.allowed());
Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application");}このモジュールは「パス・トラバーサル」を防止し、親ディレクトリへの「アクセサ」メソッドの使用を許可しません (つまり、「/usr/path/to/../file」や「../path/to/file」へのパスは許可されません)。 この API を使用してアクセスされるパスは、ベース・ディレクトリ のどれかひとつに関連しているか、path API を使用して作成されている必要があります。
パス・トラバーサル path traversal: 「ディレクトリ・トラバーサル」とも呼ばれるコンピュータ・システムへの攻撃手法。ユーザーが指定したファイル名のセキュリティ検証または無害化が不十分なことを悪用し、攻撃者がファイル・システム API に対し、本来アクセスできない「親(別)ディレクトリへの移動(トラバース)」を可能にするパス情報を与えることで、システム内の別の場所にあるパスワードや個人情報を奪取するもの。《wikipedia》
アクセサ accessor: オブジェクトの中のプロパティの値を取り出したり、変更したりする関数(メソッド)のこと。
詳しくは、@tauri-apps/plugin-fs - Security(英語サイト)をご覧ください。
「ファイル・システム」プラグインは、パスを操作するための二つの方法(「ベース・ディレクトリ」と「path API」)を提供しています。
-
ベース・ディレクトリ
操作の作業ディレクトリとして機能する baseDir が定義できるオプション引数が、どの API にもあります。
import { readFile } from '@tauri-apps/plugin-fs';const contents = await readFile('avatars/tauri.png', {baseDir: BaseDirectory.Home,});上記の例では、「Home ベース・ディレクトリ」を使用しているため、~/avatars/tauri.png ファイルが読み取られます。
-
path API(パス API)
別の方法として、「パス API」を使用してパス操作を実行することもできます。
import { readFile } from '@tauri-apps/plugin-fs';import * as path from '@tauri-apps/api/path';const home = await path.homeDir();const contents = await readFile(await path.join(home, 'avatars/tauri.png'));
この操作では、ファイルを作成し、そのハンドル(識別子)を返します。ファイルが既に存在する場合は、切り捨てられます。
import { create, BaseDirectory } from '@tauri-apps/plugin-fs';const file = await create('foo/bar.txt', { baseDir: BaseDirectory.AppData });await file.write(new TextEncoder().encode('Hello world'));await file.close();「ファイル・システム」プラグインでは、パフォーマンス向上のために「テキスト・ファイル」と「バイナリ・ファイル」を書き込むために別々の API を提供しています。
-
テキスト・ファイル
import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';const contents = JSON.stringify({ notifications: true });await writeTextFile('config.json', contents, {baseDir: BaseDirectory.AppConfig,}); -
バイナリ・ファイル
import { writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';const contents = new Uint8Array(); // fill a byte arrayawait writeFile('config', contents, {baseDir: BaseDirectory.AppConfig,});
この処理では、ファイルを開き、そのハンドルを返します。 この API を使用すると、ファイルを開く方法をより詳細に制御できます。 (読み取り専用モード、書き込み専用モード、上書きではなく追加、ファイルが存在しない場合にのみ作成、など)。
-
読み取り専用 read-only
デフォルト・モードです。
import { open, BaseDirectory } from '@tauri-apps/plugin-fs';const file = await open('foo/bar.txt', {read: true,baseDir: BaseDirectory.AppData,});const stat = await file.stat();const buf = new Uint8Array(stat.size);await file.read(buf);const textContents = new TextDecoder().decode(buf);await file.close(); -
書き込み専用 write-only
import { open, BaseDirectory } from '@tauri-apps/plugin-fs';const file = await open('foo/bar.txt', {write: true,baseDir: BaseDirectory.AppData,});await file.write(new TextEncoder().encode('Hello world'));await file.close();デフォルトでは、
file.write()呼び出しで、ファイルは切り捨てられます。 既存のコンテンツに追加する方法の詳細については、次の例を参照してください。 -
追加 append
import { open, BaseDirectory } from '@tauri-apps/plugin-fs';const file = await open('foo/bar.txt', {append: true,baseDir: BaseDirectory.AppData,});await file.write(new TextEncoder().encode('world'));await file.close();{ append: true }は{ write: true, append: true }と同じ効果を持つことに注意してください。 -
切り捨て truncate
truncateオプションが設定されていて、しかもファイルがすでに存在する場合、ファイルは長さ「0」に切り捨てられます。import { open, BaseDirectory } from '@tauri-apps/plugin-fs';const file = await open('foo/bar.txt', {write: true,truncate: true,baseDir: BaseDirectory.AppData,});await file.write(new TextEncoder().encode('world'));await file.close();このオプションでは、
writeがtrueである必要があります。このオプションは、複数の
file.write()呼び出しを使用して既存のファイルを書き換える場合は、appendオプションと一緒に使用できます。 -
作成 create
デフォルトでは、
openAPI は既存のファイルのみを開きます。ファイルが存在しない場合には作成し、存在する場合にはそのファイルを開くようにするには、createをtrueに設定してください:import { open, BaseDirectory } from '@tauri-apps/plugin-fs';const file = await open('foo/bar.txt', {write: true,create: true,baseDir: BaseDirectory.AppData,});await file.write(new TextEncoder().encode('world'));await file.close();ファイルが作成されるようにするには、
writeもappendもtrueに設定する必要があります。ファイルがすでに存在する場合にファイルを作成しないようにするには、次の
createNewを参照してください。 -
新規作成 createNew
createNewはcreate同様に動作しますが、ファイルがすでに存在する場合はファイルを作成しません。import { open, BaseDirectory } from '@tauri-apps/plugin-fs';const file = await open('foo/bar.txt', {write: true,createNew: true,baseDir: BaseDirectory.AppData,});await file.write(new TextEncoder().encode('world'));await file.close();ファイルが作成されるようにするには、
writeもtrueに設定する必要があります。
このプラグインは、パフォーマンス向上のために「テキスト・ファイル」と「バイナリ・ファイル」を読み取りに別々の API を提供しています。
-
テキスト・ファイル
import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs';const configToml = await readTextFile('config.toml', {baseDir: BaseDirectory.AppConfig,});ファイルが大きい場合は、
readTextFileLinesAPI を使用して、ストリーミング(シーケンシャルに「数行ごとの読み出し」を行なうこと)ができます:import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs';const lines = await readTextFileLines('app.logs', {baseDir: BaseDirectory.AppLog,});for await (const line of lines) {console.log(line);} -
バイナリ・ファイル
import { readFile, BaseDirectory } from '@tauri-apps/plugin-fs';const icon = await readFile('icon.png', {baseDir: BaseDirectory.Resources,});
ファイルを削除するには remove() を呼び出します。ファイルが存在しない場合はエラーが返されます。
import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';await remove('user.db', { baseDir: BaseDirectory.AppLocalData });copyFile 関数は、「ソース・パス source path」と「宛先パス destination path」を受け取ります。
それぞれのベース・ディレクトリを別々に設定する必要があることに注意してください。
import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs';await copyFile('user.db', 'user.db.bk', { fromPathBaseDir: BaseDirectory.AppLocalData, toPathBaseDir: BaseDirectory.Temp,});上記の例では、「<app-local-data>/user.db」ファイルが「$TMPDIR/user.db.bk」にコピーされます。
ファイルが存在するかどうかを確認するには、exists() 関数を使用します。
import { exists, BaseDirectory } from '@tauri-apps/plugin-fs';const tokenExists = await exists('token', { baseDir: BaseDirectory.AppLocalData,});ファイルのメタデータは、stat および lstat 関数を使用して取得できます。
「stat 関数」はシンボリック・リンクを辿ります(実際に指し示しているファイルが「スコープ」で許可されていない場合にはエラーを返します)。
一方、「lstat 関数」はシンボリック・リンクを辿らず、シンボリック・リンク自体の情報を返します。
シンボリック・リンク symlink: 「ソフト・リンク」。コンピュータのディスク上で扱うファイルやディレクトリを、本来の位置にファイルを残しつつそれとは別の場所に置いたり別名を付けてアクセスする手段。Windows では「ショートカット」、macOS では「エイリアス」と呼ばれます。《wikipedia》
import { stat, BaseDirectory } from '@tauri-apps/plugin-fs';const metadata = await stat('app.db', { baseDir: BaseDirectory.AppLocalData,});「rename 関数」は「ソース・パス」と「宛先パス」を受け取ります。
それぞれのベース・ディレクトリを別々に設定する必要があることに注意してください。
import { rename, BaseDirectory } from '@tauri-apps/plugin-fs';await rename('user.db.bk', 'user.db', { fromPathBaseDir: BaseDirectory.AppLocalData, toPathBaseDir: BaseDirectory.Temp,});上記の例では、「<app-local-data>/user.db.bk」ファイルの名前が「$TMPDIR/user.db」に変更されます。
指定されたファイルを、指定されたファイルの長さ(デフォルトは「0」)に達するまで「切り捨て」るか「拡張」します。
- 「長さ 0」に切り捨て
import { truncate } from '@tauri-apps/plugin-fs';await truncate('my_file.txt', 0, { baseDir: BaseDirectory.AppLocalData });- 「指定の長さ」に切り捨て
import { truncate, readTextFile, writeTextFile, BaseDirectory,} from '@tauri-apps/plugin-fs';
const filePath = 'file.txt';await writeTextFile(filePath, 'Hello World', { baseDir: BaseDirectory.AppLocalData,});await truncate(filePath, 7, { baseDir: BaseDirectory.AppLocalData,});const data = await readTextFile(filePath, { baseDir: BaseDirectory.AppLocalData,});console.log(data); // "Hello W"(「Hello World」を「7」文字で切り捨て)ディレクトリを作成するには、「mkdir 関数」を呼び出します:
import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs';await mkdir('images', { baseDir: BaseDirectory.AppLocalData,});「readDir 関数」はディレクトリの内容項目を再帰的にリストします:
再帰的 recursively: 「再帰的に」とは「同じ処理を同じルールで直接の対象とその下位の内容にまで適用する」ことです。たとえば「再帰的にリストする」とは対象のディレクトリの内容とそのサブディレクトリの内容までリストし、『再帰的に削除する」とはその下位のファイルまで削除する、という処理が行なわれます。
import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs';const entries = await readDir('users', { baseDir: BaseDirectory.AppLocalData });ディレクトリを削除するには remove() を呼び出します。ディレクトリが存在しない場合はエラーが返されます。
import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';await remove('images', { baseDir: BaseDirectory.AppLocalData });ディレクトリが空でない場合は、recursive オプションを true に設定する必要があります:
import { remove, BaseDirectory } from '@tauri-apps/plugin-fs';await remove('images', { baseDir: BaseDirectory.AppLocalData, recursive: true,});ディレクトリが存在するかどうかを確認するには、「exists() 関数」を使用します:
import { exists, BaseDirectory } from '@tauri-apps/plugin-fs';const tokenExists = await exists('images', { baseDir: BaseDirectory.AppLocalData,});ディレクトリのメタデータは、stat および lstat 関数を使用して取得できます。
「stat 関数」はシンボリック・リンクを辿ります(実際に指し示しているファイルが「スコープ」で許可されていない場合にはエラーを返します)。
一方、「lstat 関数」はシンボリック・リンクを辿らず、シンボリック・リンク自体の情報を返します。
import { stat, BaseDirectory } from '@tauri-apps/plugin-fs';const metadata = await stat('databases', { baseDir: BaseDirectory.AppLocalData,});ディレクトリまたはファイルの変更を監視するには、watch または watchImmediate 関数を使用します。
-
watch(監視)関数
「
watch関数」はデバウンスを発生させるため、一定の遅延後にのみイベントが発行されます:
デバウンス debounce: キー入力やマウスの移動のような特定のイベントが短時間で連続して発生した際に、各イベントを個別に処理するのではなく、ある一定時間(たとえば 数 100ミリ秒)の間イベントが発生しなかった場合にのみそれまでの処理をまとめて実行する方法。
import { watch, BaseDirectory } from '@tauri-apps/plugin-fs';await watch( 'app.log', (event) => { console.log('app.log event', event); }, { baseDir: BaseDirectory.AppLog, delayMs: 500, });-
watchImmediate(即時監視)関数
「
watchImmediate関数」は、イベントのリスナーに直ちに通知を行ないます:import { watchImmediate, BaseDirectory } from '@tauri-apps/plugin-fs';await watchImmediate('logs',(event) => {console.log('logs directory event', event);},{baseDir: BaseDirectory.AppLog,recursive: true,});
デフォルトでは、ディレクトリの監視操作は「再帰的」ではありません。
すべてのサブディレクトリの変更を再帰的に監視するには、recursive(再帰)オプションを true に設定します。
デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、capabilities 設定でアクセス権限を変更する必要があります。
詳細については「セキュリティ・レベル Capabilities」の章を参照してください。また、プラグインのアクセス権限を設定するには「プライグン・アクセス権の使用」の章のステップ・バイ・ステップ・ガイドを参照してください。
{ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "main-capability", "description": "Capability for the main window", "windows": ["main"], "permissions": [ "fs:default", { "identifier": "fs:allow-exists", "allow": [{ "path": "$APPDATA/*" }] } ]}Default Permission
This set of permissions describes the what kind of
file system access the fs plugin has enabled or denied by default.
Granted Permissions
This default permission set enables read access to the application specific directories (AppConfig, AppData, AppLocalData, AppCache, AppLog) and all files and sub directories created in it. The location of these directories depends on the operating system, where the application is run.
In general these directories need to be manually created by the application at runtime, before accessing files or folders in it is possible.
Therefore, it is also allowed to create all of these folders via
the mkdir command.
Denied Permissions
This default permission set prevents access to critical components of the Tauri application by default. On Windows the webview data folder access is denied.
This default permission set includes the following:
create-app-specific-dirsread-app-specific-dirs-recursivedeny-default
Permission Table
| Identifier | Description |
|---|---|
|
|
This allows full recursive read access to the complete application folders, files and subdirectories. |
|
|
This allows full recursive write access to the complete application folders, files and subdirectories. |
|
|
This allows non-recursive read access to the application folders. |
|
|
This allows non-recursive write access to the application folders. |
|
|
This allows full recursive read access to metadata of the application folders, including file listing and statistics. |
|
|
This allows non-recursive read access to metadata of the application folders, including file listing and statistics. |
|
|
This scope permits recursive access to the complete application folders, including sub directories and files. |
|
|
This scope permits access to all files and list content of top level directories in the application folders. |
|
|
This scope permits to list all files and folders in the application directories. |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
Enables the copy_file command without any pre-configured scope. |
|
|
Denies the copy_file command without any pre-configured scope. |
|
|
Enables the create command without any pre-configured scope. |
|
|
Denies the create command without any pre-configured scope. |
|
|
Enables the exists command without any pre-configured scope. |
|
|
Denies the exists command without any pre-configured scope. |
|
|
Enables the fstat command without any pre-configured scope. |
|
|
Denies the fstat command without any pre-configured scope. |
|
|
Enables the ftruncate command without any pre-configured scope. |
|
|
Denies the ftruncate command without any pre-configured scope. |
|
|
Enables the lstat command without any pre-configured scope. |
|
|
Denies the lstat command without any pre-configured scope. |
|
|
Enables the mkdir command without any pre-configured scope. |
|
|
Denies the mkdir command without any pre-configured scope. |
|
|
Enables the open command without any pre-configured scope. |
|
|
Denies the open command without any pre-configured scope. |
|
|
Enables the read command without any pre-configured scope. |
|
|
Denies the read command without any pre-configured scope. |
|
|
Enables the read_dir command without any pre-configured scope. |
|
|
Denies the read_dir command without any pre-configured scope. |
|
|
Enables the read_file command without any pre-configured scope. |
|
|
Denies the read_file command without any pre-configured scope. |
|
|
Enables the read_text_file command without any pre-configured scope. |
|
|
Denies the read_text_file command without any pre-configured scope. |
|
|
Enables the read_text_file_lines command without any pre-configured scope. |
|
|
Denies the read_text_file_lines command without any pre-configured scope. |
|
|
Enables the read_text_file_lines_next command without any pre-configured scope. |
|
|
Denies the read_text_file_lines_next command without any pre-configured scope. |
|
|
Enables the remove command without any pre-configured scope. |
|
|
Denies the remove command without any pre-configured scope. |
|
|
Enables the rename command without any pre-configured scope. |
|
|
Denies the rename command without any pre-configured scope. |
|
|
Enables the seek command without any pre-configured scope. |
|
|
Denies the seek command without any pre-configured scope. |
|
|
Enables the size command without any pre-configured scope. |
|
|
Denies the size command without any pre-configured scope. |
|
|
Enables the stat command without any pre-configured scope. |
|
|
Denies the stat command without any pre-configured scope. |
|
|
Enables the truncate command without any pre-configured scope. |
|
|
Denies the truncate command without any pre-configured scope. |
|
|
Enables the unwatch command without any pre-configured scope. |
|
|
Denies the unwatch command without any pre-configured scope. |
|
|
Enables the watch command without any pre-configured scope. |
|
|
Denies the watch command without any pre-configured scope. |
|
|
Enables the write command without any pre-configured scope. |
|
|
Denies the write command without any pre-configured scope. |
|
|
Enables the write_file command without any pre-configured scope. |
|
|
Denies the write_file command without any pre-configured scope. |
|
|
Enables the write_text_file command without any pre-configured scope. |
|
|
Denies the write_text_file command without any pre-configured scope. |
|
|
This permissions allows to create the application specific directories. |
|
|
This denies access to dangerous Tauri relevant files and folders by default. |
|
|
This denies read access to the
|
|
|
This denies read access to the
|
|
|
This enables all read related commands without any pre-configured accessible paths. |
|
|
This permission allows recursive read functionality on the application specific base directories. |
|
|
This enables directory read and file metadata related commands without any pre-configured accessible paths. |
|
|
This enables file read related commands without any pre-configured accessible paths. |
|
|
This enables all index or metadata related commands without any pre-configured accessible paths. |
|
|
An empty permission you can use to modify the global scope. Example
|
|
|
This enables all write related commands without any pre-configured accessible paths. |
|
|
This enables all file write related commands without any pre-configured accessible paths. |
このプラグインのアクセス権限には、どのパスが許可されるか、または明示的に拒否されるかを定義するためのスコープ(有効範囲)が含まれています。
「スコープ」の詳細については、「コマンド・スコープ」を参照してください。
「許可 allow」または「拒否 deny」のスコープのどちらにも、許可または拒否する必要があるすべてのパスをリストした配列を含める必要があります。
スコープのエントリは「{ path: string }」形式です。
スコープ・エントリでは、「$<path> 変数」を使用して、ホーム・ディレクトリ、アプリ・リソース・ディレクトリ、設定ディレクトリなどの一般的なシステムパスを参照できます。
以下の表に、参照可能な一般的なパスをすべて示します:
| Path | 変数 |
|---|---|
| appConfigDir | $APPCONFIG |
| appDataDir | $APPDATA |
| appLocalDataDir | $APPLOCALDATA |
| appcacheDir | $APPCACHE |
| applogDir | $APPLOG |
| audioDir | $AUDIO |
| cacheDir | $CACHE |
| configDir | $CONFIG |
| dataDir | $DATA |
| localDataDir | $LOCALDATA |
| desktopDir | $DESKTOP |
| documentDir | $DOCUMENT |
| downloadDir | $DOWNLOAD |
| executableDir | $EXE |
| fontDir | $FONT |
| homeDir | $HOME |
| pictureDir | $PICTURE |
| publicDir | $PUBLIC |
| runtimeDir | $RUNTIME |
| templateDir | $TEMPLATE |
| videoDir | $VIDEO |
| resourceDir | $RESOURCE |
| tempDir | $TEMP |
- グローバル・スコープ
どの fs コマンドにもスコープを適用するには、「fs:scope 権限」を使用します:
{ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "main-capability", "description": "Capability for the main window", "windows": ["main"], "permissions": [ { "identifier": "fs:scope", "allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**/*" }] } ]}ある特定のfsコマンドだけにスコープを適用するには、
アクセス権限のオブジェクト形式 { "identifier": string, "allow"?: [], "deny"?: [] } を使用します:
{ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "main-capability", "description": "Capability for the main window", "windows": ["main"], "permissions": [ { "identifier": "fs:allow-rename", "allow": [{ "path": "$HOME/**/*" }] }, { "identifier": "fs:allow-rename", "deny": [{ "path": "$HOME/.config/**/*" }] }, { "identifier": "fs:allow-exists", "allow": [{ "path": "$APPDATA/*" }] } ]}上記の例では、任意の「$APPDATA サブ・パス」(サブ・ディレクトリを含まない)を使用して exists API と rename を使用します。
【※ この日本語版は、「Jun 18, 2025 英語版」に基づいています】
© 2025 Tauri Contributors. CC-BY / MIT