snapshot of https://github.com/tauri-apps/plugins-workspace.git (v2, 2026-09-23; blobs > 131072B omitted)
Some checks failed
integration tests / run-integration-tests (windows-latest) (push) Has been cancelled
Test Rust / test (push) Has been cancelled
test plugins e2e (mobile) / ios (push) Has been cancelled
test plugins e2e / test (map[name:Windows os:windows-latest]) (push) Has been cancelled
test plugins e2e / test (map[name:macOS os:macos-latest]) (push) Has been cancelled
integration tests / run-integration-tests (macos-latest) (push) Has been cancelled
version or publish / version-or-publish (push) Failing after 0s
integration tests / run-integration-tests (ubuntu-22.04) (push) Failing after 0s
Lint JavaScript / eslint (push) Failing after 0s
Sync / sync-to-mirrors (push) Failing after 0s
test plugins e2e (mobile) / android (push) Failing after 0s
test plugins e2e / test (map[name:Linux os:ubuntu-latest]) (push) Failing after 0s
Test Rust / changes (push) Failing after 0s
Lint Rust / changes (push) Failing after 0s
Lint Rust / clippy (push) Has been skipped
Audit Rust / audit-rust (push) Failing after 1s
Audit JavaScript / audit-js (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-23 17:17:10 +05:00
commit 9ad64ec987
1469 changed files with 115067 additions and 0 deletions

232
plugins/fs/CHANGELOG.md Normal file
View File

@@ -0,0 +1,232 @@
# Changelog
## [2.5.2]
- [`db9c5998`](https://github.com/tauri-apps/plugins-workspace/commit/db9c5998feff9384f9cbbefcbe0d45937c00a1fc) ([#3531](https://github.com/tauri-apps/plugins-workspace/pull/3531) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix missing `consumer-rules.pro` on Gradle v9.
- [`f8053e65`](https://github.com/tauri-apps/plugins-workspace/commit/f8053e659e4ccd85c1f52833411ff8417cbc5e69) ([#3527](https://github.com/tauri-apps/plugins-workspace/pull/3527) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Documented Cargo feature flags in each plugin's crate-level documentation.
- [`685610ae`](https://github.com/tauri-apps/plugins-workspace/commit/685610ae782b668770d412f42a5d52d2cc9e497e) ([#3507](https://github.com/tauri-apps/plugins-workspace/pull/3507) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `fs:default` and `fs:read-app-specific-dirs-recursive` not giving any command scopes
- [`3fb27bf1`](https://github.com/tauri-apps/plugins-workspace/commit/3fb27bf13a88dd1e5aa2cc933408be02b0eafc91) ([#3504](https://github.com/tauri-apps/plugins-workspace/pull/3504) by [@vasfvitor](https://github.com/tauri-apps/plugins-workspace/../../vasfvitor)) Fixed `deny-webview-data` has no effect, and on Linux, only deny access to the webview data paths instead of the entire `$APPLOCALDATA`
## \[2.5.1]
- [`ec054013`](https://github.com/tauri-apps/plugins-workspace/commit/ec0540138bece081e9a87982091947360e61987a) ([#3323](https://github.com/tauri-apps/plugins-workspace/pull/3323) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Updated dependency `toml` from 0.9 to 1
## \[2.5.0]
- [`e97a4ded`](https://github.com/tauri-apps/plugins-workspace/commit/e97a4dedab8608d9d57029784ee8a2607ca3a996) ([#3244](https://github.com/tauri-apps/plugins-workspace/pull/3244) by [@SeijiOkuda](https://github.com/tauri-apps/plugins-workspace/../../SeijiOkuda)) Add `encoding` option for `readTextFile` and `readTextFileLines`
- [`f75d21db`](https://github.com/tauri-apps/plugins-workspace/commit/f75d21db3351d6f12adf585c2c797c20ece94f7f) ([#3360](https://github.com/tauri-apps/plugins-workspace/pull/3360) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Removed the dependency on `tauri-utils`'s `build` feature
- [`f5f68063`](https://github.com/tauri-apps/plugins-workspace/commit/f5f68063e459c33522f44a04df3120d9d039ec13) ([#3185](https://github.com/tauri-apps/plugins-workspace/pull/3185) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Enable access for security-scoped resources on iOS by automatically calling `NSURL::startAccessingSecurityScopedResource` on resource access and adding the `stopAccessingSecurityScopedResource` API.
## \[2.4.5]
- [`521cd8b3`](https://github.com/tauri-apps/plugins-workspace/commit/521cd8b372c862d96b1637775710e4d7cf2443e2) ([#3155](https://github.com/tauri-apps/plugins-workspace/pull/3155) by [@EliasStar](https://github.com/tauri-apps/plugins-workspace/../../EliasStar)) Fix off by one error in the implementation of readTextFileLines causing all lines to end with an (additional) null byte.
Issue: [#3154](https://github.com/tauri-apps/plugins-workspace/issues/3154)
PR: [#3155](https://github.com/tauri-apps/plugins-workspace/pull/3155)
## \[2.4.4]
- [`93426f85`](https://github.com/tauri-apps/plugins-workspace/commit/93426f85120f49beb9f40222bff45185a32d54a9) Fixed an issue that caused docs.rs builds to fail. No user facing changes.
## \[2.4.3]
- [`6c9b61fb`](https://github.com/tauri-apps/plugins-workspace/commit/6c9b61fb658145d13893626112fc489f7458aa17) ([#3039](https://github.com/tauri-apps/plugins-workspace/pull/3039) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) On Android, updated compileSdk to 36.
- [`6b5b1053`](https://github.com/tauri-apps/plugins-workspace/commit/6b5b1053ba8aeb789dd5cb5fb05b7e98f3b8de0b) ([#1939](https://github.com/tauri-apps/plugins-workspace/pull/1939) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Enhance error messages.
## \[2.4.2]
- [`4eb36b0f`](https://github.com/tauri-apps/plugins-workspace/commit/4eb36b0ff57acb0bb1b911c583efa3bf2f56aa32) ([#2907](https://github.com/tauri-apps/plugins-workspace/pull/2907) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fixed calling `writeFile` with `data: ReadableStream` throws `Invalid argument`
- [`515182a1`](https://github.com/tauri-apps/plugins-workspace/commit/515182a179d4439079b2b7f6927555ba5ab0b035) ([#2915](https://github.com/tauri-apps/plugins-workspace/pull/2915) by [@samhinshaw](https://github.com/tauri-apps/plugins-workspace/../../samhinshaw)) `readFile` now returns a more specific type `Promise<Uint8Array<ArrayBuffer>>` instead of the default `Promise<Uint8Array<ArrayBufferLike>`
## \[2.4.1]
- [`44a1f659`](https://github.com/tauri-apps/plugins-workspace/commit/44a1f659125a341191420e650608b0b6ff316a0e) ([#2846](https://github.com/tauri-apps/plugins-workspace/pull/2846) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `writeFile` doesn't create a new file by default when the data is a `ReadableStream`
## \[2.4.0]
- [`f209b2f2`](https://github.com/tauri-apps/plugins-workspace/commit/f209b2f23cb29133c97ad5961fb46ef794dbe063) ([#2804](https://github.com/tauri-apps/plugins-workspace/pull/2804) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Updated tauri to 2.6
## \[2.3.0]
- [`dac4d537`](https://github.com/tauri-apps/plugins-workspace/commit/dac4d53724bb3430a00a3f0119857cba32a031e8) ([#2613](https://github.com/tauri-apps/plugins-workspace/pull/2613) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Reduce the overhead of `watch` and `unwatch`
## \[2.2.1]
### bug
- [`831c35ff`](https://github.com/tauri-apps/plugins-workspace/commit/831c35ff3940e841fe4418bb4cb104038b03304b) ([#2550](https://github.com/tauri-apps/plugins-workspace/pull/2550)) Fix `writeFile` ReadableStream handling due to missing async iterator support on macOS platform
## \[2.2.0]
- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other.
## \[2.0.4]
- [`77b85507`](https://github.com/tauri-apps/plugins-workspace/commit/77b855074aad612f2b28e6a3b5881fac767a05ae) ([#2171](https://github.com/tauri-apps/plugins-workspace/pull/2171) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed docs.rs build.
## \[2.0.3]
- [`ed981027`](https://github.com/tauri-apps/plugins-workspace/commit/ed981027dd4fba7d0e2f836eb5db34d344388d73) ([#1962](https://github.com/tauri-apps/plugins-workspace/pull/1962) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of `readTextFile` and `readTextFileLines` APIs
- [`3e78173d`](https://github.com/tauri-apps/plugins-workspace/commit/3e78173df9ce90aa3b19e1f36d1f8712c5020fb6) ([#2018](https://github.com/tauri-apps/plugins-workspace/pull/2018) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix `readDir` function failing to read directories that contain broken symlinks.
- [`5092ea5e`](https://github.com/tauri-apps/plugins-workspace/commit/5092ea5e89817c0550d09b0a4ad17bf1253b23df) ([#1964](https://github.com/tauri-apps/plugins-workspace/pull/1964) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add support for using `ReadableStream<Unit8Array>` with `writeFile` API.
## \[2.0.2]
- [`77149dc4`](https://github.com/tauri-apps/plugins-workspace/commit/77149dc4320d26b413e4a6bbe82c654367c51b32) ([#1965](https://github.com/tauri-apps/plugins-workspace/pull/1965) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix `writeTextFile` converting UTF-8 characters (for example `äöü`) in the given path into replacement character (`<60>`)
## \[2.0.3]
- [`14cee64c`](https://github.com/tauri-apps/plugins-workspace/commit/14cee64c82a72655ae6a4ac0892736a2959dbda5) ([#1958](https://github.com/tauri-apps/plugins-workspace/pull/1958) by [@bWanShiTong](https://github.com/tauri-apps/plugins-workspace/../../bWanShiTong)) Fix compilation on targets with pointer width of `16` or `32`
## \[2.0.1]
- [`ae802456`](https://github.com/tauri-apps/plugins-workspace/commit/ae8024565f074f313084777c8b10d1b5e3bbe220) ([#1950](https://github.com/tauri-apps/plugins-workspace/pull/1950) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of the `FileHandle.read` and `writeTextFile` APIs.
## \[2.0.1]
- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7.
## \[2.0.0]
- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release.
## \[2.0.0-rc.6]
- [`fc9b189e`](https://github.com/tauri-apps/plugins-workspace/commit/fc9b189e83a29bd750714ec6336133c6eabdfa20) ([#1837](https://github.com/tauri-apps/plugins-workspace/pull/1837) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fix failing to deserialize capability file when using an OS specific path in the scope that is not available on the current OS.
## \[2.0.0-rc.5]
- [`cc03ccf5`](https://github.com/tauri-apps/plugins-workspace/commit/cc03ccf5e0e4be8bbf50bbdebe957c84be7f779b) ([#1774](https://github.com/tauri-apps/plugins-workspace/pull/1774)) Fix `scope-app`, `scope-app-recursive` and `scope-index` not properly enabling the application paths.
## \[2.0.0-rc.4]
- [`9291e4d2`](https://github.com/tauri-apps/plugins-workspace/commit/9291e4d2caa31c883c71e55f2193bd8754d72f03) ([#1640](https://github.com/tauri-apps/plugins-workspace/pull/1640) by [@SRutile](https://github.com/tauri-apps/plugins-workspace/../../SRutile)) Support any UTF-8 character in the writeFile API.
## \[2.0.0-rc.3]
- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add utility methods on `FilePath` and `SafeFilePath` enums which are:
- `path`
- `simplified`
- `into_path`
- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Implement `Serialize`, `Deserialize`, `From`, `TryFrom` and `FromStr` traits for `FilePath` and `SafeFilePath` enums.
- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Mark `Error` enum as `#[non_exhuastive]`.
- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add `SafeFilePath` enum.
## \[2.0.0-rc.2]
- [`f7280c88`](https://github.com/tauri-apps/plugins-workspace/commit/f7280c88309cdf1f2330574fec31e26e01e9cdbd) ([#1710](https://github.com/tauri-apps/plugins-workspace/pull/1710) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix can't use Windows paths like `C:/Users/UserName/file.txt`
### bug
- [`51819c60`](https://github.com/tauri-apps/plugins-workspace/commit/51819c601f863cbfbd11809a1c4cf9df5a20b1e0) ([#1708](https://github.com/tauri-apps/plugins-workspace/pull/1708) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Fixes `writeFile` command implementation on Android.
## \[2.0.0-rc.2]
- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8
## \[2.0.0-rc.1]
- [`5f689902`](https://github.com/tauri-apps/plugins-workspace/commit/5f68990297f2cefac4220649a469adb7fa94fe1b) ([#1645](https://github.com/tauri-apps/plugins-workspace/pull/1645) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update documentation.
## \[2.0.0-rc.0]
- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC.
## \[2.0.0-beta.8]
- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version.
- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25.
## \[2.0.0-beta.7]
- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24.
## \[2.0.0-beta.6]
- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23.
## \[2.0.0-beta.5]
- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22.
## \[2.0.0-beta.4]
- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20.
## \[2.0.0-beta.3]
- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17.
## \[2.0.0-beta.6]
- [`b115fd22`](https://github.com/tauri-apps/plugins-workspace/commit/b115fd22e0da073f5d758c13474ec2106cf78163)([#1221](https://github.com/tauri-apps/plugins-workspace/pull/1221)) Fixes an issue that caused the app to freeze when the `dialog`, `fs`, and `persisted-scope` plugins were used together.
## \[2.0.0-beta.5]
- [`bb51a41`](https://github.com/tauri-apps/plugins-workspace/commit/bb51a41d67ebf989e8aedf10c4b1a7f9514d1bdf)([#1168](https://github.com/tauri-apps/plugins-workspace/pull/1168)) **Breaking Change:** All apis that return paths to the frontend will now remove the `\\?\` UNC prefix on Windows.
- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Internally use the webview scoped resources table instead of the app one, so other webviews can't access other webviews resources.
- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Update for tauri 2.0.0-beta.15.
## \[2.0.0-beta.4]
- [`9c2fb93`](https://github.com/tauri-apps/plugins-workspace/commit/9c2fb9306ecd3936a2aef56b3c012899036db098) Enhance the scope type to also allow a plain string representing the path to allow or deny.
- [`772f2bc`](https://github.com/tauri-apps/plugins-workspace/commit/772f2bc3495a4f83f1c3e538cbac6d29cbd7d5ef)([#1136](https://github.com/tauri-apps/plugins-workspace/pull/1136)) Update for tauri 2.0.0-beta.14.
## \[2.0.0-beta.3]
- [`cb96aa0`](https://github.com/tauri-apps/plugins-workspace/commit/cb96aa06277f7b864952827ec9fb1e74c8a1f761)([#1082](https://github.com/tauri-apps/plugins-workspace/pull/1082)) Fixes `watch` and `watchImmediate` which previously ignored the `baseDir` parameter.
- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true.
## \[2.0.0-beta.2]
- [`7358102`](https://github.com/tauri-apps/plugins-workspace/commit/735810237e21504a027a65a7b3c25fd7e594288a)([#1029](https://github.com/tauri-apps/plugins-workspace/pull/1029)) Fix infinite loop on cargo build operations
- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8.
## \[2.0.0-beta.1]
- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4.
## \[2.0.0-beta.0]
- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta.
- [`ea8eadc`](https://github.com/tauri-apps/plugins-workspace/commit/ea8eadce85b2e3e8eb7eb1a779fc3aa6c1201fa3)([#865](https://github.com/tauri-apps/plugins-workspace/pull/865)) Fix incorrect `create` option default value for `writeFile` and `writeTextFile` which didn't match documentation.
- [`61edbbe`](https://github.com/tauri-apps/plugins-workspace/commit/61edbbec0acda4213ed8684f75a973e8be123a52)([#885](https://github.com/tauri-apps/plugins-workspace/pull/885)) Replace `notify-debouncer-mini` with `notify-debouncer-full`. [(plugins-workspace#885)](https://github.com/tauri-apps/plugins-workspace/pull/885)
## \[2.0.0-alpha.6]
- [`85f8419`](https://github.com/tauri-apps/plugins-workspace/commit/85f841968200316958d707db0c39bb115f762471)([#848](https://github.com/tauri-apps/plugins-workspace/pull/848)) Fix `DebouncedEvent` type to correctly represent the actual type.
- [`c601230`](https://github.com/tauri-apps/plugins-workspace/commit/c60123093ddf725af7228494182fed697ff8b021)([#847](https://github.com/tauri-apps/plugins-workspace/pull/847)) Add `createNew` option for `writeFile` and `writeTextFile` to create the file if doesn't exist and fail if it does.
- [`c601230`](https://github.com/tauri-apps/plugins-workspace/commit/c60123093ddf725af7228494182fed697ff8b021)([#847](https://github.com/tauri-apps/plugins-workspace/pull/847)) Truncate files when using `writeFile` and `writeTextFile` with `append: false`.
- [`2e2fc8d`](https://github.com/tauri-apps/plugins-workspace/commit/2e2fc8de69dd8d282b66ec81561d57d8af802dc5)([#857](https://github.com/tauri-apps/plugins-workspace/pull/857)) Fix `invalid args id for command unwatch` error when trying to unwatch a previously watched file or directory.
- [`c601230`](https://github.com/tauri-apps/plugins-workspace/commit/c60123093ddf725af7228494182fed697ff8b021)([#847](https://github.com/tauri-apps/plugins-workspace/pull/847)) Fix panic when using `writeFile` or `writeTextFile` without passing an option object.
## \[2.0.0-alpha.5]
- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13.
- [`69a1fa0`](https://github.com/tauri-apps/plugins-workspace/commit/69a1fa099c3143b6e426492f1c9d9cfbe56d2209)([#751](https://github.com/tauri-apps/plugins-workspace/pull/751)) The `fs` plugin received a major overhaul to add new APIs and changed existing APIs to be closer to Node.js and Deno APIs.
## \[2.0.0-alpha.4]
- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12.
- [`88d260d`](https://github.com/tauri-apps/plugins-workspace/commit/88d260d90130f9df4b9ce00c1ad1bf1e4b30b1c0)([#744](https://github.com/tauri-apps/plugins-workspace/pull/744)) Add second argument to `exists` function to specify base directory.
## \[2.0.0-alpha.3]
- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11.
## \[2.0.0-alpha.2]
- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9.
## \[2.0.0-alpha.2]
- [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12.
## \[2.0.0-alpha.1]
- [`0bba693`](https://github.com/tauri-apps/plugins-workspace/commit/0bba6932c09da5267a9dbf75ba52252e39458420)([#454](https://github.com/tauri-apps/plugins-workspace/pull/454)) Fix `writeBinaryFile` crashing with `command 'write_binary_file' not found`
- [`d74fc0a`](https://github.com/tauri-apps/plugins-workspace/commit/d74fc0a097996e90a37be8f57d50b7d1f6ca616f)([#555](https://github.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11.
## \[2.0.0-alpha.0]
- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!

59
plugins/fs/Cargo.toml Normal file
View File

@@ -0,0 +1,59 @@
[package]
name = "tauri-plugin-fs"
version = "2.5.2"
description = "Access the file system."
authors = { workspace = true }
license = { workspace = true }
edition = { workspace = true }
rust-version = { workspace = true }
repository = { workspace = true }
links = "tauri-plugin-fs"
exclude = [
"/banner.png",
"/guest-js",
"/package.json",
"/rollup.config.js",
"/tsconfig.json",
]
[package.metadata.platforms.support]
windows = { level = "full", notes = "Apps installed via MSI or NSIS in `perMachine` and `both` mode require admin permissions for write access in `$RESOURCES` folder" }
linux = { level = "full", notes = "No write access to `$RESOURCES` folder" }
macos = { level = "full", notes = "No write access to `$RESOURCES` folder" }
android = { level = "partial", notes = "Access is restricted to Application folder by default" }
ios = { level = "partial", notes = "Access is restricted to Application folder by default" }
[build-dependencies]
tauri-plugin = { workspace = true, features = ["build"] }
schemars = { workspace = true }
serde = { workspace = true }
toml = "1.0"
tauri-utils = { workspace = true }
[dev-dependencies]
tauri = { workspace = true, features = ["wry"] }
[dependencies]
serde = { workspace = true }
serde_json = { workspace = true }
serde_repr = "0.1"
tauri = { workspace = true }
thiserror = { workspace = true }
url = { workspace = true }
log = { workspace = true }
anyhow = "1"
glob = { workspace = true }
# TODO: Remove `serialization-compat-6` in v3
notify = { version = "8", optional = true, features = [
"serde",
"serialization-compat-6",
] }
notify-debouncer-full = { version = "0.6", optional = true }
dunce = { workspace = true }
percent-encoding = "2"
[target.'cfg(target_os = "ios")'.dependencies]
objc2-foundation = { version = "0.3", features = ["NSURL", "NSString"] }
[features]
watch = ["notify", "notify-debouncer-full"]

20
plugins/fs/LICENSE.spdx Normal file
View File

@@ -0,0 +1,20 @@
SPDXVersion: SPDX-2.1
DataLicense: CC0-1.0
PackageName: tauri
DataFormat: SPDXRef-1
PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy
PackageHomePage: https://tauri.app
PackageLicenseDeclared: Apache-2.0
PackageLicenseDeclared: MIT
PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy
PackageSummary: <text>Tauri is a rust project that enables developers to make secure
and small desktop applications using a web frontend.
</text>
PackageComment: <text>The package includes the following libraries; see
Relationship information.
</text>
Created: 2019-05-20T09:00:00Z
PackageDownloadLocation: git://github.com/tauri-apps/tauri
PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git
PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git
Creator: Person: Daniel Thompson-Yvetot

View File

@@ -0,0 +1,177 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

21
plugins/fs/LICENSE_MIT Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 - Present Tauri Apps Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

91
plugins/fs/README.md Normal file
View File

@@ -0,0 +1,91 @@
![plugin-fs](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/fs/banner.png)
Access the file system.
| Platform | Supported |
| -------- | --------- |
| Linux | ✓ |
| Windows | ✓ |
| macOS | ✓ |
| Android | ✓ |
| iOS | ✓ |
## Install
_This plugin requires a Rust version of at least **1.77.2**_
There are three general methods of installation that we can recommend.
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
2. Pull sources directly from Github using git tags / revision hashes (most secure)
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
Install the Core plugin by adding the following to your `Cargo.toml` file:
`src-tauri/Cargo.toml`
```toml
[dependencies]
tauri-plugin-fs = "2.0.0"
# alternatively with Git:
tauri-plugin-fs = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
```
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
```sh
pnpm add @tauri-apps/plugin-fs
# or
npm add @tauri-apps/plugin-fs
# or
yarn add @tauri-apps/plugin-fs
```
## Usage
First you need to register the core plugin with Tauri:
`src-tauri/src/lib.rs`
```rust
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_fs::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
```
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```javascript
import { stat } from '@tauri-apps/plugin-fs'
await stat('/path/to/file')
```
## Contributing
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
## Partners
<table>
<tbody>
<tr>
<td align="center" valign="middle">
<a href="https://crabnebula.dev" target="_blank">
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v2/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
</a>
</td>
</tr>
</tbody>
</table>
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
## License
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
MIT or MIT/Apache 2.0 where applicable.

49
plugins/fs/SECURITY.md Normal file
View File

@@ -0,0 +1,49 @@
# Security Policy
**Do not report security vulnerabilities through public GitHub issues.**
**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.**
Include as much of the following information:
- Type of issue (e.g. improper input parsing, privilege escalation, etc.)
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- The distribution affected or used to help us with reproduction of the issue
- Step-by-step instructions to reproduce the issue
- Ideally a reproduction repository
- Impact of the issue, including how an attacker might exploit the issue
We prefer to receive reports in English.
## Contact
Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new).
Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app).
## Threat Model
This plugin possibly allows access to the full filesystem available to the application process.
Depending on the operating system the access is already confined (android/ios) to only certain locations.
In other operating systems like Linux/MacOS/Windows it depends on the installation and packaging method but in most cases full
access is granted.
To prevent exposure of sensitive locations and data this plugin can be scoped to only allow certain base directories
or only access to specific files or subdirectories.
This scoping effectively affects only calls made from the webviews/frontend code and calls made from rust can always circumvent
the restrictions imposed by the scope.
The scope is defined at compile time in the used permissions but the user or application developer can grant or revoke access to specific files or folders at runtime by modifying the scope state through the runtime authority, if configured during plugin initialization.
### Security Assumptions
- The filesystem access is limited by user permissions
- The operating system filesystem access confinment works as documented
- The scoping mechanism of the Tauri `fs` commands work as intended and has no bypasses
- The user or application developer can grant or revoke access to specific files at runtime by modifying the scope
#### Out Of Scope
- Exploits in underlying filesystems
- Exploits in the underlying rust `std::fs` library

2
plugins/fs/android/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/build
/.tauri

View File

@@ -0,0 +1,36 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "com.plugin.fs"
compileSdk = 36
defaultConfig {
minSdk = 21
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.0")
implementation("com.google.android.material:material:1.7.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation(project(":tauri-android"))
}

View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,31 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
resolutionStrategy {
eachPlugin {
switch (requested.id.id) {
case "com.android.library":
useVersion("8.0.2")
break
case "org.jetbrains.kotlin.android":
useVersion("1.8.20")
break
}
}
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
google()
}
}
include ':tauri-android'
project(':tauri-android').projectDir = new File('./.tauri/tauri-api')

View File

@@ -0,0 +1,28 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
package com.plugin.fs
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.plugin.fs", appContext.packageName)
}
}

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@@ -0,0 +1,93 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
package com.plugin.fs
import android.annotation.SuppressLint
import android.app.Activity
import android.content.res.AssetManager.ACCESS_BUFFER
import android.net.Uri
import android.os.ParcelFileDescriptor
import app.tauri.annotation.Command
import app.tauri.annotation.InvokeArg
import app.tauri.annotation.TauriPlugin
import app.tauri.plugin.Invoke
import app.tauri.plugin.JSObject
import app.tauri.plugin.Plugin
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
@InvokeArg
class WriteTextFileArgs {
val uri: String = ""
val content: String = ""
}
@InvokeArg
class GetFileDescriptorArgs {
lateinit var uri: String
lateinit var mode: String
}
@TauriPlugin
class FsPlugin(private val activity: Activity): Plugin(activity) {
@SuppressLint("Recycle")
@Command
fun getFileDescriptor(invoke: Invoke) {
val args = invoke.parseArgs(GetFileDescriptorArgs::class.java)
val res = JSObject()
if (args.uri.startsWith(app.tauri.TAURI_ASSETS_DIRECTORY_URI)) {
val path = args.uri.substring(app.tauri.TAURI_ASSETS_DIRECTORY_URI.length)
try {
val fd = activity.assets.openFd(path).parcelFileDescriptor?.detachFd()
res.put("fd", fd)
} catch (e: IOException) {
// if the asset is compressed, we cannot open a file descriptor directly
// so we copy it to the cache and get a fd from there
// this is a lot faster than serializing the file and sending it as invoke response
// because on the Rust side we can leverage the custom protocol IPC and read the file directly
val cacheFile = File(activity.cacheDir, "_assets/$path")
cacheFile.parentFile?.mkdirs()
copyAsset(path, cacheFile)
val fd = ParcelFileDescriptor.open(cacheFile, ParcelFileDescriptor.parseMode(args.mode)).detachFd()
res.put("fd", fd)
}
} else {
val fd = activity.contentResolver.openAssetFileDescriptor(
Uri.parse(args.uri),
args.mode
)?.parcelFileDescriptor?.detachFd()
res.put("fd", fd)
}
invoke.resolve(res)
}
@Throws(IOException::class)
private fun copy(input: InputStream, output: OutputStream) {
val buf = ByteArray(1024)
var len: Int
while ((input.read(buf).also { len = it }) > 0) {
output.write(buf, 0, len)
}
}
@Throws(IOException::class)
private fun copyAsset(assetPath: String, cacheFile: File) {
val input = activity.assets.open(assetPath, ACCESS_BUFFER)
input.use { i ->
val output = FileOutputStream(cacheFile, false)
output.use { o ->
copy(i, o)
}
}
}
}

View File

@@ -0,0 +1,21 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
package com.plugin.fs
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

1
plugins/fs/api-iife.js Normal file

File diff suppressed because one or more lines are too long

BIN
plugins/fs/banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

269
plugins/fs/build.rs Normal file
View File

@@ -0,0 +1,269 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::{
fs::create_dir_all,
path::{Path, PathBuf},
};
use tauri_utils::acl::manifest::PermissionFile;
#[path = "src/scope.rs"]
#[allow(dead_code)]
mod scope;
/// FS scope entry.
#[derive(schemars::JsonSchema)]
#[serde(untagged)]
#[allow(unused)]
enum FsScopeEntry {
/// A path that can be accessed by the webview when using the fs APIs.
/// FS scope path pattern.
///
/// The pattern can start with a variable that resolves to a system base directory.
/// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`,
/// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`,
/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`,
/// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.
Value(PathBuf),
Object {
/// A path that can be accessed by the webview when using the fs APIs.
///
/// The pattern can start with a variable that resolves to a system base directory.
/// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`,
/// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`,
/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`,
/// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.
path: PathBuf,
},
}
// Ensure `FsScopeEntry` and `scope::EntryRaw` is kept in sync
fn _f() {
match scope::EntryRaw::Value(PathBuf::new()) {
scope::EntryRaw::Value(path) => FsScopeEntry::Value(path),
scope::EntryRaw::Object { path } => FsScopeEntry::Object { path },
};
match FsScopeEntry::Value(PathBuf::new()) {
FsScopeEntry::Value(path) => scope::EntryRaw::Value(path),
FsScopeEntry::Object { path } => scope::EntryRaw::Object { path },
};
}
const BASE_DIR_VARS: &[&str] = &[
"AUDIO",
"CACHE",
"CONFIG",
"DATA",
"LOCALDATA",
"DESKTOP",
"DOCUMENT",
"DOWNLOAD",
"EXE",
"FONT",
"HOME",
"PICTURE",
"PUBLIC",
"RUNTIME",
"TEMPLATE",
"VIDEO",
"RESOURCE",
"LOG",
"TEMP",
"APPCONFIG",
"APPDATA",
"APPLOCALDATA",
"APPCACHE",
"APPLOG",
];
const COMMANDS: &[(&str, &[&str])] = &[
("mkdir", &[]),
("create", &[]),
("copy_file", &[]),
("remove", &[]),
("rename", &[]),
("truncate", &[]),
("ftruncate", &[]),
("write", &[]),
("write_file", &["open", "write"]),
("write_text_file", &[]),
("read_dir", &[]),
("read_file", &[]),
("read", &[]),
("open", &[]),
("read_text_file", &[]),
("read_text_file_lines", &["read_text_file_lines_next"]),
("read_text_file_lines_next", &[]),
("seek", &[]),
("stat", &[]),
("lstat", &[]),
("fstat", &[]),
("exists", &[]),
("watch", &[]),
// TODO: Remove this in v3
("unwatch", &[]),
("size", &[]),
("start_accessing_security_scoped_resource", &[]),
("stop_accessing_security_scoped_resource", &[]),
];
fn main() {
let autogenerated = Path::new("permissions/autogenerated/");
let base_dirs = &autogenerated.join("base-directories");
if !base_dirs.exists() {
create_dir_all(base_dirs).expect("unable to create autogenerated base directories dir");
}
for base_dir in BASE_DIR_VARS {
let upper = base_dir;
let lower = base_dir.to_lowercase();
let toml = format!(
r###"# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-{lower}-recursive"
description = "This scope permits recursive access to the complete `${upper}` folder, including sub directories and files."
[[permission.scope.allow]]
path = "${upper}"
[[permission.scope.allow]]
path = "${upper}/**"
[[permission]]
identifier = "scope-{lower}"
description = "This scope permits access to all files and list content of top level directories in the `${upper}` folder."
[[permission.scope.allow]]
path = "${upper}"
[[permission.scope.allow]]
path = "${upper}/*"
[[permission]]
identifier = "scope-{lower}-index"
description = "This scope permits to list all files and folders in the `${upper}`folder."
[[permission.scope.allow]]
path = "${upper}"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-{lower}-read-recursive"
description = "This allows full recursive read access to the complete `${upper}` folder, files and subdirectories."
permissions = [
"read-all",
"scope-{lower}-recursive"
]
[[set]]
identifier = "allow-{lower}-write-recursive"
description = "This allows full recursive write access to the complete `${upper}` folder, files and subdirectories."
permissions = [
"write-all",
"scope-{lower}-recursive"
]
[[set]]
identifier = "allow-{lower}-read"
description = "This allows non-recursive read access to the `${upper}` folder."
permissions = [
"read-all",
"scope-{lower}"
]
[[set]]
identifier = "allow-{lower}-write"
description = "This allows non-recursive write access to the `${upper}` folder."
permissions = [
"write-all",
"scope-{lower}"
]
[[set]]
identifier = "allow-{lower}-meta-recursive"
description = "This allows full recursive read access to metadata of the `${upper}` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-{lower}-recursive"
]
[[set]]
identifier = "allow-{lower}-meta"
description = "This allows non-recursive read access to metadata of the `${upper}` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-{lower}-index"
]"###
);
let permission_path = base_dirs.join(format!("{lower}.toml"));
if toml != std::fs::read_to_string(&permission_path).unwrap_or_default() {
std::fs::write(permission_path, toml)
.unwrap_or_else(|e| panic!("unable to autogenerate ${lower}: {e}"));
}
}
tauri_plugin::Builder::new(
&COMMANDS
.iter()
// FIXME: https://docs.rs/crate/tauri-plugin-fs/2.1.0/builds/1571296
.filter(|c| c.1.is_empty())
.map(|c| c.0)
.collect::<Vec<_>>(),
)
.global_api_script_path("./api-iife.js")
.global_scope_schema(schemars::schema_for!(FsScopeEntry))
.android_path("android")
.build();
// workaround to include nested permissions as `tauri_plugin` doesn't support it
let permissions_dir = autogenerated.join("commands");
for (command, nested_commands) in COMMANDS {
if nested_commands.is_empty() {
continue;
}
let permission_path = permissions_dir.join(format!("{command}.toml"));
let content = std::fs::read_to_string(&permission_path)
.unwrap_or_else(|_| panic!("failed to read {command}.toml"));
let mut permission_file = toml::from_str::<PermissionFile>(&content)
.unwrap_or_else(|_| panic!("failed to deserialize {command}.toml"));
for p in permission_file
.permission
.iter_mut()
.filter(|p| p.identifier.starts_with("allow"))
{
for c in nested_commands.iter().map(|s| s.to_string()) {
if !p.commands.allow.contains(&c) {
p.commands.allow.push(c);
}
}
}
let out = toml::to_string_pretty(&permission_file)
.unwrap_or_else(|_| panic!("failed to serialize {command}.toml"));
let out = format!(
r#"# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
{out}"#
);
if content != out {
std::fs::write(permission_path, out)
.unwrap_or_else(|_| panic!("failed to write {command}.toml"));
}
}
}

1649
plugins/fs/guest-js/index.ts Normal file

File diff suppressed because it is too large Load Diff

30
plugins/fs/package.json Normal file
View File

@@ -0,0 +1,30 @@
{
"name": "@tauri-apps/plugin-fs",
"version": "2.5.2",
"description": "Access the file system.",
"license": "MIT OR Apache-2.0",
"authors": [
"Tauri Programme within The Commons Conservancy"
],
"repository": "https://github.com/tauri-apps/plugins-workspace",
"type": "module",
"types": "./dist-js/index.d.ts",
"main": "./dist-js/index.cjs",
"module": "./dist-js/index.js",
"exports": {
"types": "./dist-js/index.d.ts",
"import": "./dist-js/index.js",
"require": "./dist-js/index.cjs"
},
"scripts": {
"build": "rollup -c"
},
"files": [
"dist-js",
"README.md",
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "^2.11.0"
}
}

View File

@@ -0,0 +1,114 @@
"$schema" = "schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-app-recursive"
description = "This scope permits recursive access to the complete application folders, including sub directories and files."
[[permission.scope.allow]]
path = "$APPCONFIG"
[[permission.scope.allow]]
path = "$APPCONFIG/**"
[[permission.scope.allow]]
path = "$APPDATA"
[[permission.scope.allow]]
path = "$APPDATA/**"
[[permission.scope.allow]]
path = "$APPLOCALDATA"
[[permission.scope.allow]]
path = "$APPLOCALDATA/**"
[[permission.scope.allow]]
path = "$APPCACHE"
[[permission.scope.allow]]
path = "$APPCACHE/**"
[[permission.scope.allow]]
path = "$APPLOG"
[[permission.scope.allow]]
path = "$APPLOG/**"
[[permission]]
identifier = "scope-app"
description = "This scope permits access to all files and list content of top level directories in the application folders."
[[permission.scope.allow]]
path = "$APPCONFIG"
[[permission.scope.allow]]
path = "$APPCONFIG/*"
[[permission.scope.allow]]
path = "$APPDATA"
[[permission.scope.allow]]
path = "$APPDATA/*"
[[permission.scope.allow]]
path = "$APPLOCALDATA"
[[permission.scope.allow]]
path = "$APPLOCALDATA/*"
[[permission.scope.allow]]
path = "$APPCACHE"
[[permission.scope.allow]]
path = "$APPCACHE/*"
[[permission.scope.allow]]
path = "$APPLOG"
[[permission.scope.allow]]
path = "$APPLOG/*"
[[permission]]
identifier = "scope-app-index"
description = "This scope permits to list all files and folders in the application directories."
[[permission.scope.allow]]
path = "$APPCONFIG"
[[permission.scope.allow]]
path = "$APPDATA"
[[permission.scope.allow]]
path = "$APPLOCALDATA"
[[permission.scope.allow]]
path = "$APPCACHE"
[[permission.scope.allow]]
path = "$APPLOG"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-app-read-recursive"
description = "This allows full recursive read access to the complete application folders, files and subdirectories."
permissions = ["read-all", "scope-app-recursive"]
[[set]]
identifier = "allow-app-write-recursive"
description = "This allows full recursive write access to the complete application folders, files and subdirectories."
permissions = ["write-all", "scope-app-recursive"]
[[set]]
identifier = "allow-app-read"
description = "This allows non-recursive read access to the application folders."
permissions = ["read-all", "scope-app"]
[[set]]
identifier = "allow-app-write"
description = "This allows non-recursive write access to the application folders."
permissions = ["write-all", "scope-app"]
[[set]]
identifier = "allow-app-meta-recursive"
description = "This allows full recursive read access to metadata of the application folders, including file listing and statistics."
permissions = ["read-meta", "scope-app-recursive"]
[[set]]
identifier = "allow-app-meta"
description = "This allows non-recursive read access to metadata of the application folders, including file listing and statistics."
permissions = ["read-meta", "scope-app-index"]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-appcache-recursive"
description = "This scope permits recursive access to the complete `$APPCACHE` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$APPCACHE"
[[permission.scope.allow]]
path = "$APPCACHE/**"
[[permission]]
identifier = "scope-appcache"
description = "This scope permits access to all files and list content of top level directories in the `$APPCACHE` folder."
[[permission.scope.allow]]
path = "$APPCACHE"
[[permission.scope.allow]]
path = "$APPCACHE/*"
[[permission]]
identifier = "scope-appcache-index"
description = "This scope permits to list all files and folders in the `$APPCACHE`folder."
[[permission.scope.allow]]
path = "$APPCACHE"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-appcache-read-recursive"
description = "This allows full recursive read access to the complete `$APPCACHE` folder, files and subdirectories."
permissions = [
"read-all",
"scope-appcache-recursive"
]
[[set]]
identifier = "allow-appcache-write-recursive"
description = "This allows full recursive write access to the complete `$APPCACHE` folder, files and subdirectories."
permissions = [
"write-all",
"scope-appcache-recursive"
]
[[set]]
identifier = "allow-appcache-read"
description = "This allows non-recursive read access to the `$APPCACHE` folder."
permissions = [
"read-all",
"scope-appcache"
]
[[set]]
identifier = "allow-appcache-write"
description = "This allows non-recursive write access to the `$APPCACHE` folder."
permissions = [
"write-all",
"scope-appcache"
]
[[set]]
identifier = "allow-appcache-meta-recursive"
description = "This allows full recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-appcache-recursive"
]
[[set]]
identifier = "allow-appcache-meta"
description = "This allows non-recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-appcache-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-appconfig-recursive"
description = "This scope permits recursive access to the complete `$APPCONFIG` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$APPCONFIG"
[[permission.scope.allow]]
path = "$APPCONFIG/**"
[[permission]]
identifier = "scope-appconfig"
description = "This scope permits access to all files and list content of top level directories in the `$APPCONFIG` folder."
[[permission.scope.allow]]
path = "$APPCONFIG"
[[permission.scope.allow]]
path = "$APPCONFIG/*"
[[permission]]
identifier = "scope-appconfig-index"
description = "This scope permits to list all files and folders in the `$APPCONFIG`folder."
[[permission.scope.allow]]
path = "$APPCONFIG"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-appconfig-read-recursive"
description = "This allows full recursive read access to the complete `$APPCONFIG` folder, files and subdirectories."
permissions = [
"read-all",
"scope-appconfig-recursive"
]
[[set]]
identifier = "allow-appconfig-write-recursive"
description = "This allows full recursive write access to the complete `$APPCONFIG` folder, files and subdirectories."
permissions = [
"write-all",
"scope-appconfig-recursive"
]
[[set]]
identifier = "allow-appconfig-read"
description = "This allows non-recursive read access to the `$APPCONFIG` folder."
permissions = [
"read-all",
"scope-appconfig"
]
[[set]]
identifier = "allow-appconfig-write"
description = "This allows non-recursive write access to the `$APPCONFIG` folder."
permissions = [
"write-all",
"scope-appconfig"
]
[[set]]
identifier = "allow-appconfig-meta-recursive"
description = "This allows full recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-appconfig-recursive"
]
[[set]]
identifier = "allow-appconfig-meta"
description = "This allows non-recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-appconfig-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-appdata-recursive"
description = "This scope permits recursive access to the complete `$APPDATA` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$APPDATA"
[[permission.scope.allow]]
path = "$APPDATA/**"
[[permission]]
identifier = "scope-appdata"
description = "This scope permits access to all files and list content of top level directories in the `$APPDATA` folder."
[[permission.scope.allow]]
path = "$APPDATA"
[[permission.scope.allow]]
path = "$APPDATA/*"
[[permission]]
identifier = "scope-appdata-index"
description = "This scope permits to list all files and folders in the `$APPDATA`folder."
[[permission.scope.allow]]
path = "$APPDATA"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-appdata-read-recursive"
description = "This allows full recursive read access to the complete `$APPDATA` folder, files and subdirectories."
permissions = [
"read-all",
"scope-appdata-recursive"
]
[[set]]
identifier = "allow-appdata-write-recursive"
description = "This allows full recursive write access to the complete `$APPDATA` folder, files and subdirectories."
permissions = [
"write-all",
"scope-appdata-recursive"
]
[[set]]
identifier = "allow-appdata-read"
description = "This allows non-recursive read access to the `$APPDATA` folder."
permissions = [
"read-all",
"scope-appdata"
]
[[set]]
identifier = "allow-appdata-write"
description = "This allows non-recursive write access to the `$APPDATA` folder."
permissions = [
"write-all",
"scope-appdata"
]
[[set]]
identifier = "allow-appdata-meta-recursive"
description = "This allows full recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-appdata-recursive"
]
[[set]]
identifier = "allow-appdata-meta"
description = "This allows non-recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-appdata-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-applocaldata-recursive"
description = "This scope permits recursive access to the complete `$APPLOCALDATA` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$APPLOCALDATA"
[[permission.scope.allow]]
path = "$APPLOCALDATA/**"
[[permission]]
identifier = "scope-applocaldata"
description = "This scope permits access to all files and list content of top level directories in the `$APPLOCALDATA` folder."
[[permission.scope.allow]]
path = "$APPLOCALDATA"
[[permission.scope.allow]]
path = "$APPLOCALDATA/*"
[[permission]]
identifier = "scope-applocaldata-index"
description = "This scope permits to list all files and folders in the `$APPLOCALDATA`folder."
[[permission.scope.allow]]
path = "$APPLOCALDATA"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-applocaldata-read-recursive"
description = "This allows full recursive read access to the complete `$APPLOCALDATA` folder, files and subdirectories."
permissions = [
"read-all",
"scope-applocaldata-recursive"
]
[[set]]
identifier = "allow-applocaldata-write-recursive"
description = "This allows full recursive write access to the complete `$APPLOCALDATA` folder, files and subdirectories."
permissions = [
"write-all",
"scope-applocaldata-recursive"
]
[[set]]
identifier = "allow-applocaldata-read"
description = "This allows non-recursive read access to the `$APPLOCALDATA` folder."
permissions = [
"read-all",
"scope-applocaldata"
]
[[set]]
identifier = "allow-applocaldata-write"
description = "This allows non-recursive write access to the `$APPLOCALDATA` folder."
permissions = [
"write-all",
"scope-applocaldata"
]
[[set]]
identifier = "allow-applocaldata-meta-recursive"
description = "This allows full recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-applocaldata-recursive"
]
[[set]]
identifier = "allow-applocaldata-meta"
description = "This allows non-recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-applocaldata-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-applog-recursive"
description = "This scope permits recursive access to the complete `$APPLOG` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$APPLOG"
[[permission.scope.allow]]
path = "$APPLOG/**"
[[permission]]
identifier = "scope-applog"
description = "This scope permits access to all files and list content of top level directories in the `$APPLOG` folder."
[[permission.scope.allow]]
path = "$APPLOG"
[[permission.scope.allow]]
path = "$APPLOG/*"
[[permission]]
identifier = "scope-applog-index"
description = "This scope permits to list all files and folders in the `$APPLOG`folder."
[[permission.scope.allow]]
path = "$APPLOG"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-applog-read-recursive"
description = "This allows full recursive read access to the complete `$APPLOG` folder, files and subdirectories."
permissions = [
"read-all",
"scope-applog-recursive"
]
[[set]]
identifier = "allow-applog-write-recursive"
description = "This allows full recursive write access to the complete `$APPLOG` folder, files and subdirectories."
permissions = [
"write-all",
"scope-applog-recursive"
]
[[set]]
identifier = "allow-applog-read"
description = "This allows non-recursive read access to the `$APPLOG` folder."
permissions = [
"read-all",
"scope-applog"
]
[[set]]
identifier = "allow-applog-write"
description = "This allows non-recursive write access to the `$APPLOG` folder."
permissions = [
"write-all",
"scope-applog"
]
[[set]]
identifier = "allow-applog-meta-recursive"
description = "This allows full recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-applog-recursive"
]
[[set]]
identifier = "allow-applog-meta"
description = "This allows non-recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-applog-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-audio-recursive"
description = "This scope permits recursive access to the complete `$AUDIO` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$AUDIO"
[[permission.scope.allow]]
path = "$AUDIO/**"
[[permission]]
identifier = "scope-audio"
description = "This scope permits access to all files and list content of top level directories in the `$AUDIO` folder."
[[permission.scope.allow]]
path = "$AUDIO"
[[permission.scope.allow]]
path = "$AUDIO/*"
[[permission]]
identifier = "scope-audio-index"
description = "This scope permits to list all files and folders in the `$AUDIO`folder."
[[permission.scope.allow]]
path = "$AUDIO"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-audio-read-recursive"
description = "This allows full recursive read access to the complete `$AUDIO` folder, files and subdirectories."
permissions = [
"read-all",
"scope-audio-recursive"
]
[[set]]
identifier = "allow-audio-write-recursive"
description = "This allows full recursive write access to the complete `$AUDIO` folder, files and subdirectories."
permissions = [
"write-all",
"scope-audio-recursive"
]
[[set]]
identifier = "allow-audio-read"
description = "This allows non-recursive read access to the `$AUDIO` folder."
permissions = [
"read-all",
"scope-audio"
]
[[set]]
identifier = "allow-audio-write"
description = "This allows non-recursive write access to the `$AUDIO` folder."
permissions = [
"write-all",
"scope-audio"
]
[[set]]
identifier = "allow-audio-meta-recursive"
description = "This allows full recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-audio-recursive"
]
[[set]]
identifier = "allow-audio-meta"
description = "This allows non-recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-audio-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-cache-recursive"
description = "This scope permits recursive access to the complete `$CACHE` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$CACHE"
[[permission.scope.allow]]
path = "$CACHE/**"
[[permission]]
identifier = "scope-cache"
description = "This scope permits access to all files and list content of top level directories in the `$CACHE` folder."
[[permission.scope.allow]]
path = "$CACHE"
[[permission.scope.allow]]
path = "$CACHE/*"
[[permission]]
identifier = "scope-cache-index"
description = "This scope permits to list all files and folders in the `$CACHE`folder."
[[permission.scope.allow]]
path = "$CACHE"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-cache-read-recursive"
description = "This allows full recursive read access to the complete `$CACHE` folder, files and subdirectories."
permissions = [
"read-all",
"scope-cache-recursive"
]
[[set]]
identifier = "allow-cache-write-recursive"
description = "This allows full recursive write access to the complete `$CACHE` folder, files and subdirectories."
permissions = [
"write-all",
"scope-cache-recursive"
]
[[set]]
identifier = "allow-cache-read"
description = "This allows non-recursive read access to the `$CACHE` folder."
permissions = [
"read-all",
"scope-cache"
]
[[set]]
identifier = "allow-cache-write"
description = "This allows non-recursive write access to the `$CACHE` folder."
permissions = [
"write-all",
"scope-cache"
]
[[set]]
identifier = "allow-cache-meta-recursive"
description = "This allows full recursive read access to metadata of the `$CACHE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-cache-recursive"
]
[[set]]
identifier = "allow-cache-meta"
description = "This allows non-recursive read access to metadata of the `$CACHE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-cache-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-config-recursive"
description = "This scope permits recursive access to the complete `$CONFIG` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$CONFIG"
[[permission.scope.allow]]
path = "$CONFIG/**"
[[permission]]
identifier = "scope-config"
description = "This scope permits access to all files and list content of top level directories in the `$CONFIG` folder."
[[permission.scope.allow]]
path = "$CONFIG"
[[permission.scope.allow]]
path = "$CONFIG/*"
[[permission]]
identifier = "scope-config-index"
description = "This scope permits to list all files and folders in the `$CONFIG`folder."
[[permission.scope.allow]]
path = "$CONFIG"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-config-read-recursive"
description = "This allows full recursive read access to the complete `$CONFIG` folder, files and subdirectories."
permissions = [
"read-all",
"scope-config-recursive"
]
[[set]]
identifier = "allow-config-write-recursive"
description = "This allows full recursive write access to the complete `$CONFIG` folder, files and subdirectories."
permissions = [
"write-all",
"scope-config-recursive"
]
[[set]]
identifier = "allow-config-read"
description = "This allows non-recursive read access to the `$CONFIG` folder."
permissions = [
"read-all",
"scope-config"
]
[[set]]
identifier = "allow-config-write"
description = "This allows non-recursive write access to the `$CONFIG` folder."
permissions = [
"write-all",
"scope-config"
]
[[set]]
identifier = "allow-config-meta-recursive"
description = "This allows full recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-config-recursive"
]
[[set]]
identifier = "allow-config-meta"
description = "This allows non-recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-config-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-data-recursive"
description = "This scope permits recursive access to the complete `$DATA` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$DATA"
[[permission.scope.allow]]
path = "$DATA/**"
[[permission]]
identifier = "scope-data"
description = "This scope permits access to all files and list content of top level directories in the `$DATA` folder."
[[permission.scope.allow]]
path = "$DATA"
[[permission.scope.allow]]
path = "$DATA/*"
[[permission]]
identifier = "scope-data-index"
description = "This scope permits to list all files and folders in the `$DATA`folder."
[[permission.scope.allow]]
path = "$DATA"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-data-read-recursive"
description = "This allows full recursive read access to the complete `$DATA` folder, files and subdirectories."
permissions = [
"read-all",
"scope-data-recursive"
]
[[set]]
identifier = "allow-data-write-recursive"
description = "This allows full recursive write access to the complete `$DATA` folder, files and subdirectories."
permissions = [
"write-all",
"scope-data-recursive"
]
[[set]]
identifier = "allow-data-read"
description = "This allows non-recursive read access to the `$DATA` folder."
permissions = [
"read-all",
"scope-data"
]
[[set]]
identifier = "allow-data-write"
description = "This allows non-recursive write access to the `$DATA` folder."
permissions = [
"write-all",
"scope-data"
]
[[set]]
identifier = "allow-data-meta-recursive"
description = "This allows full recursive read access to metadata of the `$DATA` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-data-recursive"
]
[[set]]
identifier = "allow-data-meta"
description = "This allows non-recursive read access to metadata of the `$DATA` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-data-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-desktop-recursive"
description = "This scope permits recursive access to the complete `$DESKTOP` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$DESKTOP"
[[permission.scope.allow]]
path = "$DESKTOP/**"
[[permission]]
identifier = "scope-desktop"
description = "This scope permits access to all files and list content of top level directories in the `$DESKTOP` folder."
[[permission.scope.allow]]
path = "$DESKTOP"
[[permission.scope.allow]]
path = "$DESKTOP/*"
[[permission]]
identifier = "scope-desktop-index"
description = "This scope permits to list all files and folders in the `$DESKTOP`folder."
[[permission.scope.allow]]
path = "$DESKTOP"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-desktop-read-recursive"
description = "This allows full recursive read access to the complete `$DESKTOP` folder, files and subdirectories."
permissions = [
"read-all",
"scope-desktop-recursive"
]
[[set]]
identifier = "allow-desktop-write-recursive"
description = "This allows full recursive write access to the complete `$DESKTOP` folder, files and subdirectories."
permissions = [
"write-all",
"scope-desktop-recursive"
]
[[set]]
identifier = "allow-desktop-read"
description = "This allows non-recursive read access to the `$DESKTOP` folder."
permissions = [
"read-all",
"scope-desktop"
]
[[set]]
identifier = "allow-desktop-write"
description = "This allows non-recursive write access to the `$DESKTOP` folder."
permissions = [
"write-all",
"scope-desktop"
]
[[set]]
identifier = "allow-desktop-meta-recursive"
description = "This allows full recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-desktop-recursive"
]
[[set]]
identifier = "allow-desktop-meta"
description = "This allows non-recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-desktop-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-document-recursive"
description = "This scope permits recursive access to the complete `$DOCUMENT` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$DOCUMENT"
[[permission.scope.allow]]
path = "$DOCUMENT/**"
[[permission]]
identifier = "scope-document"
description = "This scope permits access to all files and list content of top level directories in the `$DOCUMENT` folder."
[[permission.scope.allow]]
path = "$DOCUMENT"
[[permission.scope.allow]]
path = "$DOCUMENT/*"
[[permission]]
identifier = "scope-document-index"
description = "This scope permits to list all files and folders in the `$DOCUMENT`folder."
[[permission.scope.allow]]
path = "$DOCUMENT"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-document-read-recursive"
description = "This allows full recursive read access to the complete `$DOCUMENT` folder, files and subdirectories."
permissions = [
"read-all",
"scope-document-recursive"
]
[[set]]
identifier = "allow-document-write-recursive"
description = "This allows full recursive write access to the complete `$DOCUMENT` folder, files and subdirectories."
permissions = [
"write-all",
"scope-document-recursive"
]
[[set]]
identifier = "allow-document-read"
description = "This allows non-recursive read access to the `$DOCUMENT` folder."
permissions = [
"read-all",
"scope-document"
]
[[set]]
identifier = "allow-document-write"
description = "This allows non-recursive write access to the `$DOCUMENT` folder."
permissions = [
"write-all",
"scope-document"
]
[[set]]
identifier = "allow-document-meta-recursive"
description = "This allows full recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-document-recursive"
]
[[set]]
identifier = "allow-document-meta"
description = "This allows non-recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-document-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-download-recursive"
description = "This scope permits recursive access to the complete `$DOWNLOAD` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$DOWNLOAD"
[[permission.scope.allow]]
path = "$DOWNLOAD/**"
[[permission]]
identifier = "scope-download"
description = "This scope permits access to all files and list content of top level directories in the `$DOWNLOAD` folder."
[[permission.scope.allow]]
path = "$DOWNLOAD"
[[permission.scope.allow]]
path = "$DOWNLOAD/*"
[[permission]]
identifier = "scope-download-index"
description = "This scope permits to list all files and folders in the `$DOWNLOAD`folder."
[[permission.scope.allow]]
path = "$DOWNLOAD"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-download-read-recursive"
description = "This allows full recursive read access to the complete `$DOWNLOAD` folder, files and subdirectories."
permissions = [
"read-all",
"scope-download-recursive"
]
[[set]]
identifier = "allow-download-write-recursive"
description = "This allows full recursive write access to the complete `$DOWNLOAD` folder, files and subdirectories."
permissions = [
"write-all",
"scope-download-recursive"
]
[[set]]
identifier = "allow-download-read"
description = "This allows non-recursive read access to the `$DOWNLOAD` folder."
permissions = [
"read-all",
"scope-download"
]
[[set]]
identifier = "allow-download-write"
description = "This allows non-recursive write access to the `$DOWNLOAD` folder."
permissions = [
"write-all",
"scope-download"
]
[[set]]
identifier = "allow-download-meta-recursive"
description = "This allows full recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-download-recursive"
]
[[set]]
identifier = "allow-download-meta"
description = "This allows non-recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-download-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-exe-recursive"
description = "This scope permits recursive access to the complete `$EXE` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$EXE"
[[permission.scope.allow]]
path = "$EXE/**"
[[permission]]
identifier = "scope-exe"
description = "This scope permits access to all files and list content of top level directories in the `$EXE` folder."
[[permission.scope.allow]]
path = "$EXE"
[[permission.scope.allow]]
path = "$EXE/*"
[[permission]]
identifier = "scope-exe-index"
description = "This scope permits to list all files and folders in the `$EXE`folder."
[[permission.scope.allow]]
path = "$EXE"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-exe-read-recursive"
description = "This allows full recursive read access to the complete `$EXE` folder, files and subdirectories."
permissions = [
"read-all",
"scope-exe-recursive"
]
[[set]]
identifier = "allow-exe-write-recursive"
description = "This allows full recursive write access to the complete `$EXE` folder, files and subdirectories."
permissions = [
"write-all",
"scope-exe-recursive"
]
[[set]]
identifier = "allow-exe-read"
description = "This allows non-recursive read access to the `$EXE` folder."
permissions = [
"read-all",
"scope-exe"
]
[[set]]
identifier = "allow-exe-write"
description = "This allows non-recursive write access to the `$EXE` folder."
permissions = [
"write-all",
"scope-exe"
]
[[set]]
identifier = "allow-exe-meta-recursive"
description = "This allows full recursive read access to metadata of the `$EXE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-exe-recursive"
]
[[set]]
identifier = "allow-exe-meta"
description = "This allows non-recursive read access to metadata of the `$EXE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-exe-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-font-recursive"
description = "This scope permits recursive access to the complete `$FONT` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$FONT"
[[permission.scope.allow]]
path = "$FONT/**"
[[permission]]
identifier = "scope-font"
description = "This scope permits access to all files and list content of top level directories in the `$FONT` folder."
[[permission.scope.allow]]
path = "$FONT"
[[permission.scope.allow]]
path = "$FONT/*"
[[permission]]
identifier = "scope-font-index"
description = "This scope permits to list all files and folders in the `$FONT`folder."
[[permission.scope.allow]]
path = "$FONT"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-font-read-recursive"
description = "This allows full recursive read access to the complete `$FONT` folder, files and subdirectories."
permissions = [
"read-all",
"scope-font-recursive"
]
[[set]]
identifier = "allow-font-write-recursive"
description = "This allows full recursive write access to the complete `$FONT` folder, files and subdirectories."
permissions = [
"write-all",
"scope-font-recursive"
]
[[set]]
identifier = "allow-font-read"
description = "This allows non-recursive read access to the `$FONT` folder."
permissions = [
"read-all",
"scope-font"
]
[[set]]
identifier = "allow-font-write"
description = "This allows non-recursive write access to the `$FONT` folder."
permissions = [
"write-all",
"scope-font"
]
[[set]]
identifier = "allow-font-meta-recursive"
description = "This allows full recursive read access to metadata of the `$FONT` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-font-recursive"
]
[[set]]
identifier = "allow-font-meta"
description = "This allows non-recursive read access to metadata of the `$FONT` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-font-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-home-recursive"
description = "This scope permits recursive access to the complete `$HOME` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$HOME"
[[permission.scope.allow]]
path = "$HOME/**"
[[permission]]
identifier = "scope-home"
description = "This scope permits access to all files and list content of top level directories in the `$HOME` folder."
[[permission.scope.allow]]
path = "$HOME"
[[permission.scope.allow]]
path = "$HOME/*"
[[permission]]
identifier = "scope-home-index"
description = "This scope permits to list all files and folders in the `$HOME`folder."
[[permission.scope.allow]]
path = "$HOME"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-home-read-recursive"
description = "This allows full recursive read access to the complete `$HOME` folder, files and subdirectories."
permissions = [
"read-all",
"scope-home-recursive"
]
[[set]]
identifier = "allow-home-write-recursive"
description = "This allows full recursive write access to the complete `$HOME` folder, files and subdirectories."
permissions = [
"write-all",
"scope-home-recursive"
]
[[set]]
identifier = "allow-home-read"
description = "This allows non-recursive read access to the `$HOME` folder."
permissions = [
"read-all",
"scope-home"
]
[[set]]
identifier = "allow-home-write"
description = "This allows non-recursive write access to the `$HOME` folder."
permissions = [
"write-all",
"scope-home"
]
[[set]]
identifier = "allow-home-meta-recursive"
description = "This allows full recursive read access to metadata of the `$HOME` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-home-recursive"
]
[[set]]
identifier = "allow-home-meta"
description = "This allows non-recursive read access to metadata of the `$HOME` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-home-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-localdata-recursive"
description = "This scope permits recursive access to the complete `$LOCALDATA` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$LOCALDATA"
[[permission.scope.allow]]
path = "$LOCALDATA/**"
[[permission]]
identifier = "scope-localdata"
description = "This scope permits access to all files and list content of top level directories in the `$LOCALDATA` folder."
[[permission.scope.allow]]
path = "$LOCALDATA"
[[permission.scope.allow]]
path = "$LOCALDATA/*"
[[permission]]
identifier = "scope-localdata-index"
description = "This scope permits to list all files and folders in the `$LOCALDATA`folder."
[[permission.scope.allow]]
path = "$LOCALDATA"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-localdata-read-recursive"
description = "This allows full recursive read access to the complete `$LOCALDATA` folder, files and subdirectories."
permissions = [
"read-all",
"scope-localdata-recursive"
]
[[set]]
identifier = "allow-localdata-write-recursive"
description = "This allows full recursive write access to the complete `$LOCALDATA` folder, files and subdirectories."
permissions = [
"write-all",
"scope-localdata-recursive"
]
[[set]]
identifier = "allow-localdata-read"
description = "This allows non-recursive read access to the `$LOCALDATA` folder."
permissions = [
"read-all",
"scope-localdata"
]
[[set]]
identifier = "allow-localdata-write"
description = "This allows non-recursive write access to the `$LOCALDATA` folder."
permissions = [
"write-all",
"scope-localdata"
]
[[set]]
identifier = "allow-localdata-meta-recursive"
description = "This allows full recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-localdata-recursive"
]
[[set]]
identifier = "allow-localdata-meta"
description = "This allows non-recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-localdata-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-log-recursive"
description = "This scope permits recursive access to the complete `$LOG` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$LOG"
[[permission.scope.allow]]
path = "$LOG/**"
[[permission]]
identifier = "scope-log"
description = "This scope permits access to all files and list content of top level directories in the `$LOG` folder."
[[permission.scope.allow]]
path = "$LOG"
[[permission.scope.allow]]
path = "$LOG/*"
[[permission]]
identifier = "scope-log-index"
description = "This scope permits to list all files and folders in the `$LOG`folder."
[[permission.scope.allow]]
path = "$LOG"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-log-read-recursive"
description = "This allows full recursive read access to the complete `$LOG` folder, files and subdirectories."
permissions = [
"read-all",
"scope-log-recursive"
]
[[set]]
identifier = "allow-log-write-recursive"
description = "This allows full recursive write access to the complete `$LOG` folder, files and subdirectories."
permissions = [
"write-all",
"scope-log-recursive"
]
[[set]]
identifier = "allow-log-read"
description = "This allows non-recursive read access to the `$LOG` folder."
permissions = [
"read-all",
"scope-log"
]
[[set]]
identifier = "allow-log-write"
description = "This allows non-recursive write access to the `$LOG` folder."
permissions = [
"write-all",
"scope-log"
]
[[set]]
identifier = "allow-log-meta-recursive"
description = "This allows full recursive read access to metadata of the `$LOG` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-log-recursive"
]
[[set]]
identifier = "allow-log-meta"
description = "This allows non-recursive read access to metadata of the `$LOG` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-log-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-picture-recursive"
description = "This scope permits recursive access to the complete `$PICTURE` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$PICTURE"
[[permission.scope.allow]]
path = "$PICTURE/**"
[[permission]]
identifier = "scope-picture"
description = "This scope permits access to all files and list content of top level directories in the `$PICTURE` folder."
[[permission.scope.allow]]
path = "$PICTURE"
[[permission.scope.allow]]
path = "$PICTURE/*"
[[permission]]
identifier = "scope-picture-index"
description = "This scope permits to list all files and folders in the `$PICTURE`folder."
[[permission.scope.allow]]
path = "$PICTURE"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-picture-read-recursive"
description = "This allows full recursive read access to the complete `$PICTURE` folder, files and subdirectories."
permissions = [
"read-all",
"scope-picture-recursive"
]
[[set]]
identifier = "allow-picture-write-recursive"
description = "This allows full recursive write access to the complete `$PICTURE` folder, files and subdirectories."
permissions = [
"write-all",
"scope-picture-recursive"
]
[[set]]
identifier = "allow-picture-read"
description = "This allows non-recursive read access to the `$PICTURE` folder."
permissions = [
"read-all",
"scope-picture"
]
[[set]]
identifier = "allow-picture-write"
description = "This allows non-recursive write access to the `$PICTURE` folder."
permissions = [
"write-all",
"scope-picture"
]
[[set]]
identifier = "allow-picture-meta-recursive"
description = "This allows full recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-picture-recursive"
]
[[set]]
identifier = "allow-picture-meta"
description = "This allows non-recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-picture-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-public-recursive"
description = "This scope permits recursive access to the complete `$PUBLIC` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$PUBLIC"
[[permission.scope.allow]]
path = "$PUBLIC/**"
[[permission]]
identifier = "scope-public"
description = "This scope permits access to all files and list content of top level directories in the `$PUBLIC` folder."
[[permission.scope.allow]]
path = "$PUBLIC"
[[permission.scope.allow]]
path = "$PUBLIC/*"
[[permission]]
identifier = "scope-public-index"
description = "This scope permits to list all files and folders in the `$PUBLIC`folder."
[[permission.scope.allow]]
path = "$PUBLIC"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-public-read-recursive"
description = "This allows full recursive read access to the complete `$PUBLIC` folder, files and subdirectories."
permissions = [
"read-all",
"scope-public-recursive"
]
[[set]]
identifier = "allow-public-write-recursive"
description = "This allows full recursive write access to the complete `$PUBLIC` folder, files and subdirectories."
permissions = [
"write-all",
"scope-public-recursive"
]
[[set]]
identifier = "allow-public-read"
description = "This allows non-recursive read access to the `$PUBLIC` folder."
permissions = [
"read-all",
"scope-public"
]
[[set]]
identifier = "allow-public-write"
description = "This allows non-recursive write access to the `$PUBLIC` folder."
permissions = [
"write-all",
"scope-public"
]
[[set]]
identifier = "allow-public-meta-recursive"
description = "This allows full recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-public-recursive"
]
[[set]]
identifier = "allow-public-meta"
description = "This allows non-recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-public-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-resource-recursive"
description = "This scope permits recursive access to the complete `$RESOURCE` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$RESOURCE"
[[permission.scope.allow]]
path = "$RESOURCE/**"
[[permission]]
identifier = "scope-resource"
description = "This scope permits access to all files and list content of top level directories in the `$RESOURCE` folder."
[[permission.scope.allow]]
path = "$RESOURCE"
[[permission.scope.allow]]
path = "$RESOURCE/*"
[[permission]]
identifier = "scope-resource-index"
description = "This scope permits to list all files and folders in the `$RESOURCE`folder."
[[permission.scope.allow]]
path = "$RESOURCE"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-resource-read-recursive"
description = "This allows full recursive read access to the complete `$RESOURCE` folder, files and subdirectories."
permissions = [
"read-all",
"scope-resource-recursive"
]
[[set]]
identifier = "allow-resource-write-recursive"
description = "This allows full recursive write access to the complete `$RESOURCE` folder, files and subdirectories."
permissions = [
"write-all",
"scope-resource-recursive"
]
[[set]]
identifier = "allow-resource-read"
description = "This allows non-recursive read access to the `$RESOURCE` folder."
permissions = [
"read-all",
"scope-resource"
]
[[set]]
identifier = "allow-resource-write"
description = "This allows non-recursive write access to the `$RESOURCE` folder."
permissions = [
"write-all",
"scope-resource"
]
[[set]]
identifier = "allow-resource-meta-recursive"
description = "This allows full recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-resource-recursive"
]
[[set]]
identifier = "allow-resource-meta"
description = "This allows non-recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-resource-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-runtime-recursive"
description = "This scope permits recursive access to the complete `$RUNTIME` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$RUNTIME"
[[permission.scope.allow]]
path = "$RUNTIME/**"
[[permission]]
identifier = "scope-runtime"
description = "This scope permits access to all files and list content of top level directories in the `$RUNTIME` folder."
[[permission.scope.allow]]
path = "$RUNTIME"
[[permission.scope.allow]]
path = "$RUNTIME/*"
[[permission]]
identifier = "scope-runtime-index"
description = "This scope permits to list all files and folders in the `$RUNTIME`folder."
[[permission.scope.allow]]
path = "$RUNTIME"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-runtime-read-recursive"
description = "This allows full recursive read access to the complete `$RUNTIME` folder, files and subdirectories."
permissions = [
"read-all",
"scope-runtime-recursive"
]
[[set]]
identifier = "allow-runtime-write-recursive"
description = "This allows full recursive write access to the complete `$RUNTIME` folder, files and subdirectories."
permissions = [
"write-all",
"scope-runtime-recursive"
]
[[set]]
identifier = "allow-runtime-read"
description = "This allows non-recursive read access to the `$RUNTIME` folder."
permissions = [
"read-all",
"scope-runtime"
]
[[set]]
identifier = "allow-runtime-write"
description = "This allows non-recursive write access to the `$RUNTIME` folder."
permissions = [
"write-all",
"scope-runtime"
]
[[set]]
identifier = "allow-runtime-meta-recursive"
description = "This allows full recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-runtime-recursive"
]
[[set]]
identifier = "allow-runtime-meta"
description = "This allows non-recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-runtime-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-temp-recursive"
description = "This scope permits recursive access to the complete `$TEMP` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$TEMP"
[[permission.scope.allow]]
path = "$TEMP/**"
[[permission]]
identifier = "scope-temp"
description = "This scope permits access to all files and list content of top level directories in the `$TEMP` folder."
[[permission.scope.allow]]
path = "$TEMP"
[[permission.scope.allow]]
path = "$TEMP/*"
[[permission]]
identifier = "scope-temp-index"
description = "This scope permits to list all files and folders in the `$TEMP`folder."
[[permission.scope.allow]]
path = "$TEMP"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-temp-read-recursive"
description = "This allows full recursive read access to the complete `$TEMP` folder, files and subdirectories."
permissions = [
"read-all",
"scope-temp-recursive"
]
[[set]]
identifier = "allow-temp-write-recursive"
description = "This allows full recursive write access to the complete `$TEMP` folder, files and subdirectories."
permissions = [
"write-all",
"scope-temp-recursive"
]
[[set]]
identifier = "allow-temp-read"
description = "This allows non-recursive read access to the `$TEMP` folder."
permissions = [
"read-all",
"scope-temp"
]
[[set]]
identifier = "allow-temp-write"
description = "This allows non-recursive write access to the `$TEMP` folder."
permissions = [
"write-all",
"scope-temp"
]
[[set]]
identifier = "allow-temp-meta-recursive"
description = "This allows full recursive read access to metadata of the `$TEMP` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-temp-recursive"
]
[[set]]
identifier = "allow-temp-meta"
description = "This allows non-recursive read access to metadata of the `$TEMP` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-temp-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-template-recursive"
description = "This scope permits recursive access to the complete `$TEMPLATE` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$TEMPLATE"
[[permission.scope.allow]]
path = "$TEMPLATE/**"
[[permission]]
identifier = "scope-template"
description = "This scope permits access to all files and list content of top level directories in the `$TEMPLATE` folder."
[[permission.scope.allow]]
path = "$TEMPLATE"
[[permission.scope.allow]]
path = "$TEMPLATE/*"
[[permission]]
identifier = "scope-template-index"
description = "This scope permits to list all files and folders in the `$TEMPLATE`folder."
[[permission.scope.allow]]
path = "$TEMPLATE"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-template-read-recursive"
description = "This allows full recursive read access to the complete `$TEMPLATE` folder, files and subdirectories."
permissions = [
"read-all",
"scope-template-recursive"
]
[[set]]
identifier = "allow-template-write-recursive"
description = "This allows full recursive write access to the complete `$TEMPLATE` folder, files and subdirectories."
permissions = [
"write-all",
"scope-template-recursive"
]
[[set]]
identifier = "allow-template-read"
description = "This allows non-recursive read access to the `$TEMPLATE` folder."
permissions = [
"read-all",
"scope-template"
]
[[set]]
identifier = "allow-template-write"
description = "This allows non-recursive write access to the `$TEMPLATE` folder."
permissions = [
"write-all",
"scope-template"
]
[[set]]
identifier = "allow-template-meta-recursive"
description = "This allows full recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-template-recursive"
]
[[set]]
identifier = "allow-template-meta"
description = "This allows non-recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-template-index"
]

View File

@@ -0,0 +1,82 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
# Scopes Section
# This section contains scopes, which define file level access
[[permission]]
identifier = "scope-video-recursive"
description = "This scope permits recursive access to the complete `$VIDEO` folder, including sub directories and files."
[[permission.scope.allow]]
path = "$VIDEO"
[[permission.scope.allow]]
path = "$VIDEO/**"
[[permission]]
identifier = "scope-video"
description = "This scope permits access to all files and list content of top level directories in the `$VIDEO` folder."
[[permission.scope.allow]]
path = "$VIDEO"
[[permission.scope.allow]]
path = "$VIDEO/*"
[[permission]]
identifier = "scope-video-index"
description = "This scope permits to list all files and folders in the `$VIDEO`folder."
[[permission.scope.allow]]
path = "$VIDEO"
# Sets Section
# This section combines the scope elements with enablement of commands
[[set]]
identifier = "allow-video-read-recursive"
description = "This allows full recursive read access to the complete `$VIDEO` folder, files and subdirectories."
permissions = [
"read-all",
"scope-video-recursive"
]
[[set]]
identifier = "allow-video-write-recursive"
description = "This allows full recursive write access to the complete `$VIDEO` folder, files and subdirectories."
permissions = [
"write-all",
"scope-video-recursive"
]
[[set]]
identifier = "allow-video-read"
description = "This allows non-recursive read access to the `$VIDEO` folder."
permissions = [
"read-all",
"scope-video"
]
[[set]]
identifier = "allow-video-write"
description = "This allows non-recursive write access to the `$VIDEO` folder."
permissions = [
"write-all",
"scope-video"
]
[[set]]
identifier = "allow-video-meta-recursive"
description = "This allows full recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-video-recursive"
]
[[set]]
identifier = "allow-video-meta"
description = "This allows non-recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics."
permissions = [
"read-meta",
"scope-video-index"
]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-copy-file"
description = "Enables the copy_file command without any pre-configured scope."
commands.allow = ["copy_file"]
[[permission]]
identifier = "deny-copy-file"
description = "Denies the copy_file command without any pre-configured scope."
commands.deny = ["copy_file"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-create"
description = "Enables the create command without any pre-configured scope."
commands.allow = ["create"]
[[permission]]
identifier = "deny-create"
description = "Denies the create command without any pre-configured scope."
commands.deny = ["create"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-exists"
description = "Enables the exists command without any pre-configured scope."
commands.allow = ["exists"]
[[permission]]
identifier = "deny-exists"
description = "Denies the exists command without any pre-configured scope."
commands.deny = ["exists"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-fstat"
description = "Enables the fstat command without any pre-configured scope."
commands.allow = ["fstat"]
[[permission]]
identifier = "deny-fstat"
description = "Denies the fstat command without any pre-configured scope."
commands.deny = ["fstat"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-ftruncate"
description = "Enables the ftruncate command without any pre-configured scope."
commands.allow = ["ftruncate"]
[[permission]]
identifier = "deny-ftruncate"
description = "Denies the ftruncate command without any pre-configured scope."
commands.deny = ["ftruncate"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-lstat"
description = "Enables the lstat command without any pre-configured scope."
commands.allow = ["lstat"]
[[permission]]
identifier = "deny-lstat"
description = "Denies the lstat command without any pre-configured scope."
commands.deny = ["lstat"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-mkdir"
description = "Enables the mkdir command without any pre-configured scope."
commands.allow = ["mkdir"]
[[permission]]
identifier = "deny-mkdir"
description = "Denies the mkdir command without any pre-configured scope."
commands.deny = ["mkdir"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-open"
description = "Enables the open command without any pre-configured scope."
commands.allow = ["open"]
[[permission]]
identifier = "deny-open"
description = "Denies the open command without any pre-configured scope."
commands.deny = ["open"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-read"
description = "Enables the read command without any pre-configured scope."
commands.allow = ["read"]
[[permission]]
identifier = "deny-read"
description = "Denies the read command without any pre-configured scope."
commands.deny = ["read"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-read-dir"
description = "Enables the read_dir command without any pre-configured scope."
commands.allow = ["read_dir"]
[[permission]]
identifier = "deny-read-dir"
description = "Denies the read_dir command without any pre-configured scope."
commands.deny = ["read_dir"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-read-file"
description = "Enables the read_file command without any pre-configured scope."
commands.allow = ["read_file"]
[[permission]]
identifier = "deny-read-file"
description = "Denies the read_file command without any pre-configured scope."
commands.deny = ["read_file"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-read-text-file"
description = "Enables the read_text_file command without any pre-configured scope."
commands.allow = ["read_text_file"]
[[permission]]
identifier = "deny-read-text-file"
description = "Denies the read_text_file command without any pre-configured scope."
commands.deny = ["read_text_file"]

View File

@@ -0,0 +1,22 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-read-text-file-lines"
description = "Enables the read_text_file_lines command without any pre-configured scope."
[permission.commands]
allow = [
"read_text_file_lines",
"read_text_file_lines_next",
]
deny = []
[[permission]]
identifier = "deny-read-text-file-lines"
description = "Denies the read_text_file_lines command without any pre-configured scope."
[permission.commands]
allow = []
deny = ["read_text_file_lines"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-read-text-file-lines-next"
description = "Enables the read_text_file_lines_next command without any pre-configured scope."
commands.allow = ["read_text_file_lines_next"]
[[permission]]
identifier = "deny-read-text-file-lines-next"
description = "Denies the read_text_file_lines_next command without any pre-configured scope."
commands.deny = ["read_text_file_lines_next"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-remove"
description = "Enables the remove command without any pre-configured scope."
commands.allow = ["remove"]
[[permission]]
identifier = "deny-remove"
description = "Denies the remove command without any pre-configured scope."
commands.deny = ["remove"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-rename"
description = "Enables the rename command without any pre-configured scope."
commands.allow = ["rename"]
[[permission]]
identifier = "deny-rename"
description = "Denies the rename command without any pre-configured scope."
commands.deny = ["rename"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-seek"
description = "Enables the seek command without any pre-configured scope."
commands.allow = ["seek"]
[[permission]]
identifier = "deny-seek"
description = "Denies the seek command without any pre-configured scope."
commands.deny = ["seek"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-size"
description = "Enables the size command without any pre-configured scope."
commands.allow = ["size"]
[[permission]]
identifier = "deny-size"
description = "Denies the size command without any pre-configured scope."
commands.deny = ["size"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-start-accessing-security-scoped-resource"
description = "Enables the start_accessing_security_scoped_resource command without any pre-configured scope."
commands.allow = ["start_accessing_security_scoped_resource"]
[[permission]]
identifier = "deny-start-accessing-security-scoped-resource"
description = "Denies the start_accessing_security_scoped_resource command without any pre-configured scope."
commands.deny = ["start_accessing_security_scoped_resource"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-stat"
description = "Enables the stat command without any pre-configured scope."
commands.allow = ["stat"]
[[permission]]
identifier = "deny-stat"
description = "Denies the stat command without any pre-configured scope."
commands.deny = ["stat"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-stop-accessing-security-scoped-resource"
description = "Enables the stop_accessing_security_scoped_resource command without any pre-configured scope."
commands.allow = ["stop_accessing_security_scoped_resource"]
[[permission]]
identifier = "deny-stop-accessing-security-scoped-resource"
description = "Denies the stop_accessing_security_scoped_resource command without any pre-configured scope."
commands.deny = ["stop_accessing_security_scoped_resource"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-truncate"
description = "Enables the truncate command without any pre-configured scope."
commands.allow = ["truncate"]
[[permission]]
identifier = "deny-truncate"
description = "Denies the truncate command without any pre-configured scope."
commands.deny = ["truncate"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-unwatch"
description = "Enables the unwatch command without any pre-configured scope."
commands.allow = ["unwatch"]
[[permission]]
identifier = "deny-unwatch"
description = "Denies the unwatch command without any pre-configured scope."
commands.deny = ["unwatch"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-watch"
description = "Enables the watch command without any pre-configured scope."
commands.allow = ["watch"]
[[permission]]
identifier = "deny-watch"
description = "Denies the watch command without any pre-configured scope."
commands.deny = ["watch"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-write"
description = "Enables the write command without any pre-configured scope."
commands.allow = ["write"]
[[permission]]
identifier = "deny-write"
description = "Denies the write command without any pre-configured scope."
commands.deny = ["write"]

View File

@@ -0,0 +1,23 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-write-file"
description = "Enables the write_file command without any pre-configured scope."
[permission.commands]
allow = [
"write_file",
"open",
"write",
]
deny = []
[[permission]]
identifier = "deny-write-file"
description = "Denies the write_file command without any pre-configured scope."
[permission.commands]
allow = []
deny = ["write_file"]

View File

@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-write-text-file"
description = "Enables the write_text_file command without any pre-configured scope."
commands.allow = ["write_text_file"]
[[permission]]
identifier = "deny-write-text-file"
description = "Denies the write_text_file command without any pre-configured scope."
commands.deny = ["write_text_file"]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
"$schema" = "schemas/schema.json"
[[set]]
identifier = "create-app-specific-dirs"
description = """
This permissions allows to create the application specific directories.
"""
permissions = ["allow-mkdir", "scope-app-index"]

View File

@@ -0,0 +1,35 @@
"$schema" = "schemas/schema.json"
[default]
description = """
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 access to webview data folder `$APPLOCALDATA/EBWebView` is denied.
- On Linux the access to webview data paths inside `$APPLOCALDATA` are denied.
"""
permissions = [
"create-app-specific-dirs",
"read-app-specific-dirs-recursive",
"deny-default",
]

View File

@@ -0,0 +1,6 @@
"$schema" = "schemas/schema.json"
[[set]]
identifier = "deny-default"
description = "This denies access to dangerous Tauri relevant files and folders by default."
permissions = ["deny-webview-data-linux", "deny-webview-data-windows"]

View File

@@ -0,0 +1,48 @@
"$schema" = "schemas/schema.json"
[[permission]]
identifier = "deny-webview-data-linux"
description = """This denies access to the following paths
- `$APPLOCALDATA/CacheStorage/**`
- `$APPLOCALDATA/cookies`
- `$APPLOCALDATA/hsts-storage.sqlite`
- `$APPLOCALDATA/serviceworkers/**`
- `$APPLOCALDATA/WebKitCache/**`
- `$APPLOCALDATA/databases/**`
- `$APPLOCALDATA/localstorage/**`
- `$APPLOCALDATA/mediakeys/**`
- `$APPLOCALDATA/storage/**`
on linux as the webview data and configuration values are stored here.
Allowing access can lead to sensitive information disclosure and should be well considered."""
platforms = ["linux"]
[[permission.scope.deny]]
path = "$APPLOCALDATA/CacheStorage/**"
[[permission.scope.deny]]
path = "$APPLOCALDATA/cookies"
[[permission.scope.deny]]
path = "$APPLOCALDATA/hsts-storage.sqlite"
[[permission.scope.deny]]
path = "$APPLOCALDATA/serviceworkers/**"
[[permission.scope.deny]]
path = "$APPLOCALDATA/WebKitCache/**"
[[permission.scope.deny]]
path = "$APPLOCALDATA/databases/**"
[[permission.scope.deny]]
path = "$APPLOCALDATA/localstorage/**"
[[permission.scope.deny]]
path = "$APPLOCALDATA/mediakeys/**"
[[permission.scope.deny]]
path = "$APPLOCALDATA/storage/**"
[[permission]]
identifier = "deny-webview-data-windows"
description = """This denies access to the
`$APPLOCALDATA/EBWebView` folder on windows as the webview data and configuration values are stored here.
Allowing access can lead to sensitive information disclosure and should be well considered."""
platforms = ["windows"]
[[permission.scope.deny]]
path = "$APPLOCALDATA/EBWebView/**"

View File

@@ -0,0 +1,21 @@
"$schema" = "schemas/schema.json"
[[permission]]
identifier = "read-all"
description = "This enables all read related commands without any pre-configured accessible paths."
commands.allow = [
"read_dir",
"read_file",
"read",
"open",
"read_text_file",
"read_text_file_lines",
"read_text_file_lines_next",
"seek",
"stat",
"lstat",
"fstat",
"exists",
"watch",
"unwatch",
]

View File

@@ -0,0 +1,17 @@
"$schema" = "schemas/schema.json"
[[set]]
identifier = "read-app-specific-dirs-recursive"
description = """
This permission allows recursive read functionality on the application
specific base directories.
"""
permissions = [
"allow-read-dir",
"allow-read-file",
"allow-read-text-file",
"allow-read-text-file-lines",
"allow-read-text-file-lines-next",
"allow-exists",
"scope-app-recursive",
]

View File

@@ -0,0 +1,6 @@
"$schema" = "schemas/schema.json"
[[permission]]
identifier = "read-dirs"
description = "This enables directory read and file metadata related commands without any pre-configured accessible paths."
commands.allow = ["read_dir", "stat", "lstat", "fstat", "exists"]

View File

@@ -0,0 +1,19 @@
"$schema" = "schemas/schema.json"
[[permission]]
identifier = "read-files"
description = "This enables file read related commands without any pre-configured accessible paths."
commands.allow = [
"read_file",
"read",
"open",
"read_text_file",
"read_text_file_lines",
"read_text_file_lines_next",
"seek",
"stat",
"lstat",
"fstat",
"exists",
]

View File

@@ -0,0 +1,6 @@
"$schema" = "schemas/schema.json"
[[permission]]
identifier = "read-meta"
description = "This enables all index or metadata related commands without any pre-configured accessible paths."
commands.allow = ["read_dir", "stat", "lstat", "fstat", "exists", "size"]

View File

@@ -0,0 +1,28 @@
"$schema" = "schemas/schema.json"
[[permission]]
identifier = "scope"
description = """
An empty permission you can use to modify the global scope.
## Example
```json
{
"identifier": "read-documents",
"windows": ["main"],
"permissions": [
"fs:allow-read",
{
"identifier": "fs:scope",
"allow": [
"$APPDATA/documents/**/*"
],
"deny": [
"$APPDATA/documents/secret.txt"
]
}
]
}
```
"""

View File

@@ -0,0 +1,17 @@
"$schema" = "schemas/schema.json"
[[permission]]
identifier = "write-all"
description = "This enables all write related commands without any pre-configured accessible paths."
commands.allow = [
"mkdir",
"create",
"copy_file",
"remove",
"rename",
"truncate",
"ftruncate",
"write",
"write_file",
"write_text_file",
]

View File

@@ -0,0 +1,16 @@
"$schema" = "schemas/schema.json"
[[permission]]
identifier = "write-files"
description = "This enables all file write related commands without any pre-configured accessible paths."
commands.allow = [
"create",
"copy_file",
"remove",
"rename",
"truncate",
"ftruncate",
"write",
"write_file",
"write_text_file",
]

View File

@@ -0,0 +1,7 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { createConfig } from '../../shared/rollup.config.js'
export default createConfig()

92
plugins/fs/src/android.rs Normal file
View File

@@ -0,0 +1,92 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use serde::de::DeserializeOwned;
use tauri::{plugin::PluginApi, AppHandle, Runtime};
use crate::{models::*, FilePath, OpenOptions};
const PLUGIN_IDENTIFIER: &str = "com.plugin.fs";
/// Access to the file system APIs on Android.
///
/// In addition to regular file system paths, it can read `content://` URIs
/// and Android asset paths by resolving them with the Android plugin implementation.
///
/// Retrieved with [`crate::FsExt::fs`].
pub struct Fs<R: Runtime>(tauri::plugin::PluginHandle<R>);
pub fn init<R: Runtime, C: DeserializeOwned>(
_app: &AppHandle<R>,
api: PluginApi<R, C>,
) -> crate::Result<Fs<R>> {
let handle = api
.register_android_plugin(PLUGIN_IDENTIFIER, "FsPlugin")
.unwrap();
Ok(Fs(handle))
}
impl<R: Runtime> Fs<R> {
/// Open a file.
///
/// # Platform-specific
///
/// - **iOS**: This method will automatically start accessing a security-scoped resource if the path is a file URL.
/// You must call `stop_accessing_security_scoped_resource` when you're done accessing the file.
pub fn open<P: Into<FilePath>>(
&self,
path: P,
opts: OpenOptions,
) -> std::io::Result<std::fs::File> {
match path.into() {
FilePath::Url(u) => self
.resolve_content_uri(u.to_string(), opts.android_mode())
.map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("failed to open file: {e}"),
)
}),
FilePath::Path(p) => {
// tauri::utils::platform::resources_dir() returns a PathBuf with the Android asset URI prefix
// we must resolve that file with the Android API
if p.strip_prefix(tauri::utils::platform::ANDROID_ASSET_PROTOCOL_URI_PREFIX)
.is_ok()
{
self.resolve_content_uri(p.to_string_lossy(), opts.android_mode())
.map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("failed to open file: {e}"),
)
})
} else {
std::fs::OpenOptions::from(opts).open(p)
}
}
}
}
fn resolve_content_uri(
&self,
uri: impl Into<String>,
mode: impl Into<String>,
) -> crate::Result<std::fs::File> {
let result = self.0.run_mobile_plugin::<GetFileDescriptorResponse>(
"getFileDescriptor",
GetFileDescriptorPayload {
uri: uri.into(),
mode: mode.into(),
},
)?;
if let Some(fd) = result.fd {
Ok(unsafe {
use std::os::fd::FromRawFd;
std::fs::File::from_raw_fd(fd)
})
} else {
unimplemented!()
}
}
}

1885
plugins/fs/src/commands.rs Normal file

File diff suppressed because it is too large Load Diff

19
plugins/fs/src/config.rs Normal file
View File

@@ -0,0 +1,19 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use serde::Deserialize;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Config {
/// Whether or not paths that contain components that start with a `.`
/// will require that `.` appears literally in the pattern; `*`, `?`, `**`,
/// or `[...]` will not match. This is useful because such files are
/// conventionally considered hidden on Unix systems and it might be
/// desirable to skip them when listing files.
///
/// Defaults to `true` on Unix systems and `false` on Windows
// dotfiles are not supposed to be exposed by default on unix
pub require_literal_leading_dot: Option<bool>,
}

44
plugins/fs/src/desktop.rs Normal file
View File

@@ -0,0 +1,44 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::path::PathBuf;
use tauri::{AppHandle, Runtime};
use crate::{FilePath, OpenOptions};
/// Access to the file system APIs on desktop.
///
/// Retrieved with [`crate::FsExt::fs`].
pub struct Fs<R: Runtime>(pub(crate) AppHandle<R>);
fn path_or_err<P: Into<FilePath>>(p: P) -> std::io::Result<PathBuf> {
match p.into() {
FilePath::Path(p) => Ok(p),
FilePath::Url(u) if u.scheme() == "file" => u
.to_file_path()
.map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidInput, "invalid file URL")),
FilePath::Url(_) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"cannot use a URL to load files on desktop and iOS",
)),
}
}
impl<R: Runtime> Fs<R> {
/// Open a file.
///
/// # Platform-specific
///
/// - **iOS**: This method will automatically start accessing a security-scoped resource if the path is a file URL.
/// You must call `stop_accessing_security_scoped_resource` when you're done accessing the file.
pub fn open<P: Into<FilePath>>(
&self,
path: P,
opts: OpenOptions,
) -> std::io::Result<std::fs::File> {
let path = path_or_err(path)?;
std::fs::OpenOptions::from(opts).open(path)
}
}

51
plugins/fs/src/error.rs Normal file
View File

@@ -0,0 +1,51 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::path::PathBuf;
use serde::{Serialize, Serializer};
/// Errors that can happen while using the file system plugin.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
/// JSON serialization or deserialization error.
#[error(transparent)]
Json(#[from] serde_json::Error),
/// Error from the Tauri APIs, usually raised while resolving a path or a scope entry.
#[error(transparent)]
Tauri(#[from] tauri::Error),
/// Error from the underlying file system operation.
#[error(transparent)]
Io(#[from] std::io::Error),
/// The path is denied by the plugin scope or is not allowed by it.
#[error("forbidden path: {0}")]
PathForbidden(PathBuf),
/// Invalid glob pattern.
#[error("invalid glob pattern: {0}")]
GlobPattern(#[from] glob::PatternError),
/// Watcher error.
#[cfg(feature = "watch")]
#[error(transparent)]
Watch(#[from] notify::Error),
/// Error invoking the Android plugin implementation.
#[cfg(target_os = "android")]
#[error(transparent)]
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
/// The URL cannot be converted to a file system path.
#[error("URL is not a valid path")]
InvalidPathUrl,
/// The path is not safe to use, for instance because it traverses parent directories.
#[error("Unsafe PathBuf: {0}")]
UnsafePathBuf(&'static str),
}
impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}

308
plugins/fs/src/file_path.rs Normal file
View File

@@ -0,0 +1,308 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::{
convert::Infallible,
path::{Path, PathBuf},
str::FromStr,
};
use serde::Serialize;
use tauri::path::SafePathBuf;
use crate::{Error, Result};
/// Represents either a filesystem path or a URI pointing to a file
/// such as `file://` URIs or Android `content://` URIs.
#[derive(Debug, Serialize, Clone)]
#[serde(untagged)]
pub enum FilePath {
/// `file://` URIs or Android `content://` URIs.
Url(url::Url),
/// Regular [`PathBuf`]
Path(PathBuf),
}
/// Represents either a safe filesystem path or a URI pointing to a file
/// such as `file://` URIs or Android `content://` URIs.
#[derive(Debug, Clone, Serialize)]
pub enum SafeFilePath {
/// `file://` URIs or Android `content://` URIs.
Url(url::Url),
/// Safe [`PathBuf`], see [`SafePathBuf``].
Path(SafePathBuf),
}
impl FilePath {
/// Get a reference to the contained [`Path`] if the variant is [`FilePath::Path`].
///
/// Use [`FilePath::into_path`] to try to convert the [`FilePath::Url`] variant as well.
#[inline]
pub fn as_path(&self) -> Option<&Path> {
match self {
Self::Url(_) => None,
Self::Path(p) => Some(p),
}
}
/// Try to convert into [`PathBuf`] if possible.
///
/// This calls [`Url::to_file_path`](url::Url::to_file_path) if the variant is [`FilePath::Url`],
/// otherwise returns the contained [PathBuf] as is.
#[inline]
pub fn into_path(self) -> Result<PathBuf> {
match self {
Self::Url(url) => url.to_file_path().map_err(|_| Error::InvalidPathUrl),
Self::Path(p) => Ok(p),
}
}
/// Takes the contained [`PathBuf`] if the variant is [`FilePath::Path`],
/// and when possible, converts Windows UNC paths to regular paths.
#[inline]
pub fn simplified(self) -> Self {
match self {
Self::Url(url) => Self::Url(url),
Self::Path(p) => Self::Path(dunce::simplified(&p).to_path_buf()),
}
}
}
impl SafeFilePath {
/// Get a reference to the contained [`Path`] if the variant is [`SafeFilePath::Path`].
///
/// Use [`SafeFilePath::into_path`] to try to convert the [`SafeFilePath::Url`] variant as well.
#[inline]
pub fn as_path(&self) -> Option<&Path> {
match self {
Self::Url(_) => None,
Self::Path(p) => Some(p.as_ref()),
}
}
/// Try to convert into [`PathBuf`] if possible.
///
/// This calls [`Url::to_file_path`](url::Url::to_file_path) if the variant is [`SafeFilePath::Url`],
/// otherwise returns the contained [PathBuf] as is.
#[inline]
pub fn into_path(self) -> Result<PathBuf> {
match self {
Self::Url(url) => url.to_file_path().map_err(|_| Error::InvalidPathUrl),
Self::Path(p) => Ok(p.as_ref().to_owned()),
}
}
/// Takes the contained [`PathBuf`] if the variant is [`SafeFilePath::Path`],
/// and when possible, converts Windows UNC paths to regular paths.
#[inline]
pub fn simplified(self) -> Self {
match self {
Self::Url(url) => Self::Url(url),
Self::Path(p) => {
// Safe to unwrap since it was a safe file path already
Self::Path(SafePathBuf::new(dunce::simplified(p.as_ref()).to_path_buf()).unwrap())
}
}
}
}
impl std::fmt::Display for FilePath {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Url(u) => u.fmt(f),
Self::Path(p) => p.display().fmt(f),
}
}
}
impl std::fmt::Display for SafeFilePath {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Url(u) => u.fmt(f),
Self::Path(p) => p.display().fmt(f),
}
}
}
impl<'de> serde::Deserialize<'de> for FilePath {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
struct FilePathVisitor;
impl serde::de::Visitor<'_> for FilePathVisitor {
type Value = FilePath;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
formatter.write_str("a string representing an file URL or a path")
}
fn visit_str<E>(self, s: &str) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
FilePath::from_str(s).map_err(|e| {
serde::de::Error::invalid_value(
serde::de::Unexpected::Str(s),
&e.to_string().as_str(),
)
})
}
}
deserializer.deserialize_str(FilePathVisitor)
}
}
impl<'de> serde::Deserialize<'de> for SafeFilePath {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
struct SafeFilePathVisitor;
impl serde::de::Visitor<'_> for SafeFilePathVisitor {
type Value = SafeFilePath;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
formatter.write_str("a string representing an file URL or a path")
}
fn visit_str<E>(self, s: &str) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
SafeFilePath::from_str(s).map_err(|e| {
serde::de::Error::invalid_value(
serde::de::Unexpected::Str(s),
&e.to_string().as_str(),
)
})
}
}
deserializer.deserialize_str(SafeFilePathVisitor)
}
}
impl FromStr for FilePath {
type Err = Infallible;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
if let Ok(url) = url::Url::from_str(s) {
if url.scheme().len() != 1 {
return Ok(Self::Url(url));
}
}
Ok(Self::Path(PathBuf::from(s)))
}
}
impl FromStr for SafeFilePath {
type Err = Error;
fn from_str(s: &str) -> Result<Self> {
if let Ok(url) = url::Url::from_str(s) {
if url.scheme().len() != 1 {
return Ok(Self::Url(url));
}
}
SafePathBuf::new(s.into())
.map(SafeFilePath::Path)
.map_err(Error::UnsafePathBuf)
}
}
impl From<PathBuf> for FilePath {
fn from(value: PathBuf) -> Self {
Self::Path(value)
}
}
impl TryFrom<PathBuf> for SafeFilePath {
type Error = Error;
fn try_from(value: PathBuf) -> Result<Self> {
SafePathBuf::new(value)
.map(SafeFilePath::Path)
.map_err(Error::UnsafePathBuf)
}
}
impl From<&Path> for FilePath {
fn from(value: &Path) -> Self {
Self::Path(value.to_owned())
}
}
impl TryFrom<&Path> for SafeFilePath {
type Error = Error;
fn try_from(value: &Path) -> Result<Self> {
SafePathBuf::new(value.to_path_buf())
.map(SafeFilePath::Path)
.map_err(Error::UnsafePathBuf)
}
}
impl From<&PathBuf> for FilePath {
fn from(value: &PathBuf) -> Self {
Self::Path(value.to_owned())
}
}
impl TryFrom<&PathBuf> for SafeFilePath {
type Error = Error;
fn try_from(value: &PathBuf) -> Result<Self> {
SafePathBuf::new(value.to_owned())
.map(SafeFilePath::Path)
.map_err(Error::UnsafePathBuf)
}
}
impl From<url::Url> for FilePath {
fn from(value: url::Url) -> Self {
Self::Url(value)
}
}
impl From<url::Url> for SafeFilePath {
fn from(value: url::Url) -> Self {
Self::Url(value)
}
}
impl TryFrom<FilePath> for PathBuf {
type Error = Error;
fn try_from(value: FilePath) -> Result<Self> {
value.into_path()
}
}
impl TryFrom<SafeFilePath> for PathBuf {
type Error = Error;
fn try_from(value: SafeFilePath) -> Result<Self> {
value.into_path()
}
}
impl From<SafeFilePath> for FilePath {
fn from(value: SafeFilePath) -> Self {
match value {
SafeFilePath::Url(url) => FilePath::Url(url),
SafeFilePath::Path(p) => FilePath::Path(p.as_ref().to_owned()),
}
}
}
impl TryFrom<FilePath> for SafeFilePath {
type Error = Error;
fn try_from(value: FilePath) -> Result<Self> {
match value {
FilePath::Url(url) => Ok(SafeFilePath::Url(url)),
FilePath::Path(p) => SafePathBuf::new(p)
.map(SafeFilePath::Path)
.map_err(Error::UnsafePathBuf),
}
}
}

142
plugins/fs/src/ios.rs Normal file
View File

@@ -0,0 +1,142 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use serde::de::DeserializeOwned;
use tauri::{plugin::PluginApi, AppHandle, Runtime};
use crate::{FilePath, OpenOptions};
/// Access to the file system APIs on iOS.
///
/// Opening a `file://` URL automatically starts accessing the matching security-scoped resource.
///
/// Retrieved with [`crate::FsExt::fs`].
pub struct Fs<R: Runtime> {
_phantom: std::marker::PhantomData<fn() -> R>,
}
pub fn init<R: Runtime, C: DeserializeOwned>(
_app: &AppHandle<R>,
_api: PluginApi<R, C>,
) -> crate::Result<Fs<R>> {
Ok(Fs {
_phantom: std::marker::PhantomData,
})
}
impl<R: Runtime> Fs<R> {
/// Open a file.
///
/// # Platform-specific
///
/// - **iOS**: This method will automatically start accessing a security-scoped resource if the path is a file URL.
/// You must call [`Self::stop_accessing_security_scoped_resource`] when you're done accessing the file.
pub fn open<P: Into<FilePath>>(
&self,
path: P,
opts: OpenOptions,
) -> std::io::Result<std::fs::File> {
use objc2_foundation::{NSString, NSURL};
match path.into() {
FilePath::Url(url) if url.scheme() == "file" => {
// Handle security-scoped URLs on iOS
let url_string = url.as_str();
let url_nsstring = NSString::from_str(url_string);
// Create NSURL from the URL string
// URLWithString may return None for invalid URLs, but file:// URLs should be valid
let ns_url = unsafe { NSURL::URLWithString(&url_nsstring) };
if let Some(ns_url) = ns_url {
// Start accessing the security-scoped resource
// This is required for files outside the app's sandbox (e.g., from file picker)
// Note: We don't call stopAccessingSecurityScopedResource here because
// the file handle needs to remain accessible while the File is in use.
// The access will be automatically stopped when the app is backgrounded or terminated.
unsafe {
let success = ns_url.startAccessingSecurityScopedResource();
if success {
log::debug!(
"Started accessing security-scoped resource for URL: {}",
url_string
);
} else {
log::warn!(
"Failed to start accessing security-scoped resource for URL: {}",
url_string
);
}
}
} else {
log::debug!("Failed to create NSURL from URL: {}, ignoring security-scoped resource access request", url_string);
}
// Convert URL to path and open the file
let path = url.to_file_path().map_err(|_| {
std::io::Error::new(std::io::ErrorKind::InvalidInput, "invalid file URL")
})?;
std::fs::OpenOptions::from(opts).open(path)
}
FilePath::Url(_) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"cannot use a non-file URL to load files on iOS",
)),
FilePath::Path(p) => {
// Regular path, no security-scoped resource handling needed
std::fs::OpenOptions::from(opts).open(p)
}
}
}
/// Stops accessing a security-scoped resource for the given file path or URL.
/// This should be called when you're done accessing a file that was opened
/// using a security-scoped URL (e.g., from a file picker).
///
/// # Arguments
///
/// * `path` - A file path or URL that was previously accessed via `startAccessingSecurityScopedResource`
///
/// # Returns
///
/// Returns `Ok(())` if successful, or an error if the path/URL is invalid or not a file URL.
pub fn stop_accessing_security_scoped_resource<P: Into<FilePath>>(
&self,
path: P,
) -> crate::Result<()> {
use objc2_foundation::{NSString, NSURL};
let file_path = path.into();
let url_string = match file_path {
FilePath::Url(url) => {
if url.scheme() != "file" {
return Err(crate::Error::InvalidPathUrl);
}
url.as_str().to_string()
}
FilePath::Path(p) => {
// Convert path to file URL
url::Url::from_file_path(&p)
.map_err(|_| crate::Error::InvalidPathUrl)?
.as_str()
.to_string()
}
};
let url_nsstring = NSString::from_str(&url_string);
let ns_url = unsafe { NSURL::URLWithString(&url_nsstring) };
if let Some(ns_url) = ns_url {
// Stop accessing the security-scoped resource
unsafe {
ns_url.stopAccessingSecurityScopedResource();
}
} else {
return Err(crate::Error::Io(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"failed to create NSURL from URL",
)));
}
Ok(())
}
}

632
plugins/fs/src/lib.rs Normal file
View File

@@ -0,0 +1,632 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
//! Access the file system.
//!
//! ## Cargo features
//!
//! - **watch**: Enables the `watch` command backed by [`notify`](http://crates.io/crates/notify).
// TODO(v3): consider redesign the API to implement automatic stopAccessingSecurityScopedResource on iOS
// this likely requires returning a handle to a resource so we can impl Drop for it
#![doc(
html_logo_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png",
html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png"
)]
use std::io::Read;
#[cfg(target_os = "ios")]
use std::sync::Mutex;
use serde::Deserialize;
use tauri::{
ipc::ScopeObject,
plugin::{Builder as PluginBuilder, TauriPlugin},
utils::{acl::Value, config::FsScope},
AppHandle, DragDropEvent, Manager, RunEvent, Runtime, WindowEvent,
};
#[cfg(target_os = "android")]
mod android;
mod commands;
mod config;
#[cfg(desktop)]
mod desktop;
mod error;
mod file_path;
#[cfg(target_os = "ios")]
mod ios;
#[cfg(target_os = "android")]
mod models;
mod scope;
#[cfg(feature = "watch")]
mod watcher;
#[cfg(target_os = "android")]
pub use android::Fs;
#[cfg(desktop)]
pub use desktop::Fs;
#[cfg(target_os = "ios")]
pub use ios::Fs;
pub use error::Error;
pub use file_path::FilePath;
pub use file_path::SafeFilePath;
type Result<T> = std::result::Result<T, Error>;
/// Options and flags which can be used to configure how a file is opened.
///
/// This builder exposes the ability to configure how a [`std::fs::File`] is opened and
/// what operations are permitted on the open file. Build it with [`OpenOptions::new`],
/// chain calls to the setter methods and pass it to [`Fs::open`].
///
/// The `read` option defaults to `true`, every other option defaults to `false`.
#[derive(Debug, Default, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OpenOptions {
#[serde(default = "default_true")]
read: bool,
#[serde(default)]
write: bool,
#[serde(default)]
append: bool,
#[serde(default)]
truncate: bool,
#[serde(default)]
create: bool,
#[serde(default)]
create_new: bool,
#[serde(default)]
#[allow(unused)]
mode: Option<u32>,
#[serde(default)]
#[allow(unused)]
custom_flags: Option<i32>,
}
fn default_true() -> bool {
true
}
impl From<OpenOptions> for std::fs::OpenOptions {
fn from(open_options: OpenOptions) -> Self {
let mut opts = std::fs::OpenOptions::new();
#[cfg(unix)]
{
use std::os::unix::fs::OpenOptionsExt;
if let Some(mode) = open_options.mode {
opts.mode(mode);
}
if let Some(flags) = open_options.custom_flags {
opts.custom_flags(flags);
}
}
opts.read(open_options.read)
.write(open_options.write)
.create(open_options.create)
.append(open_options.append)
.truncate(open_options.truncate)
.create_new(open_options.create_new);
opts
}
}
impl OpenOptions {
/// Creates a blank new set of options ready for configuration.
///
/// All options are initially set to `false`.
///
/// # Examples
///
/// ```rust,no_run
/// use std::path::Path;
/// use tauri_plugin_fs::{FsExt, OpenOptions};
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let mut options = OpenOptions::new();
/// options.read(true);
/// let file = app.fs().open(Path::new("foo.txt"), options)?;
/// Ok(())
/// });
/// ```
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the option for read access.
///
/// This option, when true, will indicate that the file should be
/// `read`-able if opened.
///
/// # Examples
///
/// ```rust,no_run
/// use std::path::Path;
/// use tauri_plugin_fs::{FsExt, OpenOptions};
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let mut options = OpenOptions::new();
/// options.read(true);
/// let file = app.fs().open(Path::new("foo.txt"), options)?;
/// Ok(())
/// });
/// ```
pub fn read(&mut self, read: bool) -> &mut Self {
self.read = read;
self
}
/// Sets the option for write access.
///
/// This option, when true, will indicate that the file should be
/// `write`-able if opened.
///
/// If the file already exists, any write calls on it will overwrite its
/// contents, without truncating it.
///
/// # Examples
///
/// ```rust,no_run
/// use std::path::Path;
/// use tauri_plugin_fs::{FsExt, OpenOptions};
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let mut options = OpenOptions::new();
/// options.write(true);
/// let file = app.fs().open(Path::new("foo.txt"), options)?;
/// Ok(())
/// });
/// ```
pub fn write(&mut self, write: bool) -> &mut Self {
self.write = write;
self
}
/// Sets the option for the append mode.
///
/// This option, when true, means that writes will append to a file instead
/// of overwriting previous contents.
/// Note that setting `.write(true).append(true)` has the same effect as
/// setting only `.append(true)`.
///
/// Append mode guarantees that writes will be positioned at the current end of file,
/// even when there are other processes or threads appending to the same file. This is
/// unlike <code>[seek]\([SeekFrom]::[End]\(0))</code> followed by `write()`, which
/// has a race between seeking and writing during which another writer can write, with
/// our `write()` overwriting their data.
///
/// Keep in mind that this does not necessarily guarantee that data appended by
/// different processes or threads does not interleave. The amount of data accepted a
/// single `write()` call depends on the operating system and file system. A
/// successful `write()` is allowed to write only part of the given data, so even if
/// you're careful to provide the whole message in a single call to `write()`, there
/// is no guarantee that it will be written out in full. If you rely on the filesystem
/// accepting the message in a single write, make sure that all data that belongs
/// together is written in one operation. This can be done by concatenating strings
/// before passing them to [`write()`].
///
/// If a file is opened with both read and append access, beware that after
/// opening, and after every write, the position for reading may be set at the
/// end of the file. So, before writing, save the current position (using
/// <code>[Seek]::[stream_position]</code>), and restore it before the next read.
///
/// ## Note
///
/// This function doesn't create the file if it doesn't exist. Use the
/// [`OpenOptions::create`] method to do so.
///
/// [`write()`]: std::io::Write::write "io::Write::write"
/// [`flush()`]: std::io::Write::flush "io::Write::flush"
/// [Seek]: std::io::Seek "io::Seek"
/// [stream_position]: std::io::Seek::stream_position "io::Seek::stream_position"
/// [seek]: std::io::Seek::seek "io::Seek::seek"
/// [SeekFrom]: std::io::SeekFrom "io::SeekFrom"
/// [Current]: std::io::SeekFrom::Current "io::SeekFrom::Current"
/// [End]: std::io::SeekFrom::End "io::SeekFrom::End"
///
/// # Examples
///
/// ```rust,no_run
/// use std::path::Path;
/// use tauri_plugin_fs::{FsExt, OpenOptions};
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let mut options = OpenOptions::new();
/// options.append(true);
/// let file = app.fs().open(Path::new("foo.txt"), options)?;
/// Ok(())
/// });
/// ```
pub fn append(&mut self, append: bool) -> &mut Self {
self.append = append;
self
}
/// Sets the option for truncating a previous file.
///
/// If a file is successfully opened with this option set it will truncate
/// the file to 0 length if it already exists.
///
/// The file must be opened with write access for truncate to work.
///
/// # Examples
///
/// ```rust,no_run
/// use std::path::Path;
/// use tauri_plugin_fs::{FsExt, OpenOptions};
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let mut options = OpenOptions::new();
/// options.write(true).truncate(true);
/// let file = app.fs().open(Path::new("foo.txt"), options)?;
/// Ok(())
/// });
/// ```
pub fn truncate(&mut self, truncate: bool) -> &mut Self {
self.truncate = truncate;
self
}
/// Sets the option to create a new file, or open it if it already exists.
///
/// In order for the file to be created, [`OpenOptions::write`] or
/// [`OpenOptions::append`] access must be used.
///
///
/// # Examples
///
/// ```rust,no_run
/// use std::path::Path;
/// use tauri_plugin_fs::{FsExt, OpenOptions};
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let mut options = OpenOptions::new();
/// options.write(true).create(true);
/// let file = app.fs().open(Path::new("foo.txt"), options)?;
/// Ok(())
/// });
/// ```
pub fn create(&mut self, create: bool) -> &mut Self {
self.create = create;
self
}
/// Sets the option to create a new file, failing if it already exists.
///
/// No file is allowed to exist at the target location, also no (dangling) symlink. In this
/// way, if the call succeeds, the file returned is guaranteed to be new.
/// If a file exists at the target location, creating a new file will fail with [`AlreadyExists`]
/// or another error based on the situation. See [`std::fs::OpenOptions::open`] for a
/// non-exhaustive list of likely errors.
///
/// This option is useful because it is atomic. Otherwise between checking
/// whether a file exists and creating a new one, the file may have been
/// created by another process (a TOCTOU race condition / attack).
///
/// If `.create_new(true)` is set, [`.create()`] and [`.truncate()`] are
/// ignored.
///
/// The file must be opened with write or append access in order to create
/// a new file.
///
/// [`.create()`]: OpenOptions::create
/// [`.truncate()`]: OpenOptions::truncate
/// [`AlreadyExists`]: std::io::ErrorKind::AlreadyExists
///
/// # Examples
///
/// ```rust,no_run
/// use std::path::Path;
/// use tauri_plugin_fs::{FsExt, OpenOptions};
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let mut options = OpenOptions::new();
/// options.write(true).create_new(true);
/// let file = app.fs().open(Path::new("foo.txt"), options)?;
/// Ok(())
/// });
/// ```
pub fn create_new(&mut self, create_new: bool) -> &mut Self {
self.create_new = create_new;
self
}
}
#[cfg(unix)]
impl std::os::unix::fs::OpenOptionsExt for OpenOptions {
fn custom_flags(&mut self, flags: i32) -> &mut Self {
self.custom_flags.replace(flags);
self
}
fn mode(&mut self, mode: u32) -> &mut Self {
self.mode.replace(mode);
self
}
}
impl OpenOptions {
#[cfg(target_os = "android")]
fn android_mode(&self) -> String {
let mut mode = String::new();
if self.read {
mode.push('r');
}
if self.write {
mode.push('w');
}
if self.truncate {
mode.push('t');
}
if self.append {
mode.push('a');
}
mode
}
}
impl<R: Runtime> Fs<R> {
/// Reads the entire contents of a file into a string.
///
/// The file is opened in read-only mode with [`Fs::open`].
///
/// # Errors
///
/// Returns an error if `path` cannot be opened for reading or if its
/// contents are not valid UTF-8.
pub fn read_to_string<P: Into<FilePath>>(&self, path: P) -> std::io::Result<String> {
let mut s = String::new();
self.open(
path,
OpenOptions {
read: true,
..Default::default()
},
)?
.read_to_string(&mut s)?;
Ok(s)
}
/// Reads the entire contents of a file into a bytes vector.
///
/// The file is opened in read-only mode with [`Fs::open`].
///
/// # Errors
///
/// Returns an error if `path` cannot be opened for reading.
pub fn read<P: Into<FilePath>>(&self, path: P) -> std::io::Result<Vec<u8>> {
let mut buf = Vec::new();
self.open(
path,
OpenOptions {
read: true,
..Default::default()
},
)?
.read_to_end(&mut buf)?;
Ok(buf)
}
}
// implement ScopeObject here instead of in the scope module because it is also used on the build script
// and we don't want to add tauri as a build dependency
impl ScopeObject for scope::Entry {
type Error = Error;
fn deserialize<R: Runtime>(
app: &AppHandle<R>,
raw: Value,
) -> std::result::Result<Self, Self::Error> {
let path = serde_json::from_value(raw.into()).map(|raw| match raw {
scope::EntryRaw::Value(path) => path,
scope::EntryRaw::Object { path } => path,
})?;
match app.path().parse(path) {
Ok(path) => Ok(Self { path: Some(path) }),
#[cfg(not(target_os = "android"))]
Err(tauri::Error::UnknownPath) => Ok(Self { path: None }),
Err(err) => Err(err.into()),
}
}
}
pub(crate) struct Scope {
pub(crate) scope: tauri::fs::Scope,
pub(crate) require_literal_leading_dot: Option<bool>,
}
/// Tracks which paths have active security-scoped resource access on iOS.
#[cfg(target_os = "ios")]
pub(crate) struct SecurityScopedResources {
/// Set of file URLs that are currently accessing security-scoped resources.
/// The key is the URL string representation.
pub(crate) active_urls: Mutex<std::collections::HashSet<String>>,
}
#[cfg(target_os = "ios")]
impl SecurityScopedResources {
pub(crate) fn new() -> Self {
Self {
active_urls: Mutex::new(std::collections::HashSet::new()),
}
}
pub(crate) fn is_tracked_manually(&self, url: &str) -> bool {
self.active_urls.lock().unwrap().contains(url)
}
pub(crate) fn track_manually(&self, url: String) {
self.active_urls.lock().unwrap().insert(url);
}
pub(crate) fn remove(&self, url: &str) {
self.active_urls.lock().unwrap().remove(url);
}
}
#[cfg(not(target_os = "ios"))]
pub(crate) struct SecurityScopedResources;
#[cfg(not(target_os = "ios"))]
impl SecurityScopedResources {
pub(crate) fn new() -> Self {
Self
}
#[allow(dead_code)] // Used on iOS, but not on other platforms
pub(crate) fn is_tracked_manually(&self, _url: &str) -> bool {
false
}
#[allow(dead_code)] // Used on iOS, but not on other platforms
pub(crate) fn track_manually(&self, _url: String) {}
#[allow(dead_code)] // Used on iOS, but not on other platforms
pub(crate) fn remove(&self, _url: &str) {}
}
/// Extension trait implemented by every [`Manager`] (the app handle, windows, webviews, ...)
/// to access the file system plugin APIs.
///
/// # Examples
///
/// ```rust,no_run
/// use std::path::Path;
/// use tauri::Runtime;
/// use tauri_plugin_fs::FsExt;
///
/// fn setup<R: Runtime>(app: &tauri::App<R>) -> Result<(), Box<dyn std::error::Error>> {
/// // allow the app to access a directory that is not part of the static scope
/// app.fs_scope().allow_directory(Path::new("/path/to/directory"), true)?;
///
/// let contents = app.fs().read_to_string(Path::new("/path/to/directory/file.txt"))?;
/// println!("{contents}");
///
/// Ok(())
/// }
/// ```
pub trait FsExt<R: Runtime> {
/// Returns the file system scope, which can be used to dynamically
/// allow or deny paths at runtime.
///
/// # Panics
///
/// Panics if the plugin is not registered in the app.
/// Use [`FsExt::try_fs_scope`] if the plugin might not be registered.
fn fs_scope(&self) -> tauri::fs::Scope;
/// Returns the file system scope, or `None` if the plugin is not registered in the app.
fn try_fs_scope(&self) -> Option<tauri::fs::Scope>;
/// Cross platform file system APIs that also support manipulating Android files.
fn fs(&self) -> &Fs<R>;
}
impl<R: Runtime, T: Manager<R>> FsExt<R> for T {
fn fs_scope(&self) -> tauri::fs::Scope {
self.state::<Scope>().scope.clone()
}
fn try_fs_scope(&self) -> Option<tauri::fs::Scope> {
self.try_state::<Scope>().map(|s| s.scope.clone())
}
fn fs(&self) -> &Fs<R> {
self.state::<Fs<R>>().inner()
}
}
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R, Option<config::Config>> {
PluginBuilder::<R, Option<config::Config>>::new("fs")
.invoke_handler(tauri::generate_handler![
commands::create,
commands::open,
commands::copy_file,
commands::mkdir,
commands::read_dir,
commands::read,
commands::read_file,
commands::read_text_file,
commands::read_text_file_lines,
commands::read_text_file_lines_next,
commands::remove,
commands::rename,
commands::seek,
commands::stat,
commands::lstat,
commands::fstat,
commands::truncate,
commands::ftruncate,
commands::write,
commands::write_file,
commands::write_text_file,
commands::exists,
commands::size,
commands::start_accessing_security_scoped_resource,
commands::stop_accessing_security_scoped_resource,
#[cfg(feature = "watch")]
watcher::watch,
])
.setup(|app, api| {
let scope = Scope {
require_literal_leading_dot: api
.config()
.as_ref()
.and_then(|c| c.require_literal_leading_dot),
scope: tauri::fs::Scope::new(app, &FsScope::default())?,
};
#[cfg(target_os = "android")]
{
let fs = android::init(app, api)?;
app.manage(fs);
}
#[cfg(target_os = "ios")]
{
let fs = ios::init(app, api)?;
app.manage(fs);
}
#[cfg(desktop)]
app.manage(Fs(app.clone()));
app.manage(scope);
app.manage(SecurityScopedResources::new());
Ok(())
})
.on_event(|app, event| {
if let RunEvent::WindowEvent {
label: _,
event: WindowEvent::DragDrop(DragDropEvent::Drop { paths, position: _ }),
..
} = event
{
let scope = app.fs_scope();
for path in paths {
if path.is_file() {
let _ = scope.allow_file(path);
} else {
let _ = scope.allow_directory(path, true);
}
}
}
})
.build()
}

18
plugins/fs/src/models.rs Normal file
View File

@@ -0,0 +1,18 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetFileDescriptorPayload {
pub uri: String,
pub mode: String,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetFileDescriptorResponse {
pub fd: Option<i32>,
}

19
plugins/fs/src/scope.rs Normal file
View File

@@ -0,0 +1,19 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::path::PathBuf;
use serde::Deserialize;
#[derive(Debug)]
pub struct Entry {
pub path: Option<PathBuf>,
}
#[derive(Deserialize)]
#[serde(untagged)]
pub(crate) enum EntryRaw {
Value(PathBuf),
Object { path: PathBuf },
}

104
plugins/fs/src/watcher.rs Normal file
View File

@@ -0,0 +1,104 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
use notify_debouncer_full::{new_debouncer, DebouncedEvent, Debouncer, RecommendedCache};
use serde::Deserialize;
use tauri::{
ipc::{Channel, CommandScope, GlobalScope},
path::BaseDirectory,
Manager, Resource, ResourceId, Runtime, Webview,
};
use std::time::Duration;
use crate::{
commands::{resolve_path, CommandResult},
scope::Entry,
SafeFilePath,
};
#[allow(unused)]
enum WatcherKind {
Debouncer(Debouncer<RecommendedWatcher, RecommendedCache>),
Watcher(RecommendedWatcher),
}
impl Resource for WatcherKind {}
#[derive(Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WatchOptions {
base_dir: Option<BaseDirectory>,
#[serde(default)]
recursive: bool,
delay_ms: Option<u64>,
}
#[tauri::command]
pub fn watch<R: Runtime>(
webview: Webview<R>,
paths: Vec<SafeFilePath>,
options: WatchOptions,
on_event: Channel<notify::Event>,
global_scope: GlobalScope<Entry>,
command_scope: CommandScope<Entry>,
) -> CommandResult<ResourceId> {
let resolved_paths = paths
.into_iter()
.map(|path| {
resolve_path(
"watch",
&webview,
&global_scope,
&command_scope,
path,
options.base_dir,
)
})
.collect::<CommandResult<Vec<_>>>()?;
let recursive_mode = if options.recursive {
RecursiveMode::Recursive
} else {
RecursiveMode::NonRecursive
};
let watcher_kind = if let Some(delay) = options.delay_ms {
let mut debouncer = new_debouncer(
Duration::from_millis(delay),
None,
move |events: Result<Vec<DebouncedEvent>, Vec<notify::Error>>| {
if let Ok(events) = events {
for event in events {
// TODO: Should errors be emitted too?
let _ = on_event.send(event.event);
}
}
},
)?;
for path in &resolved_paths {
debouncer.watch(path, recursive_mode)?;
}
WatcherKind::Debouncer(debouncer)
} else {
let mut watcher = RecommendedWatcher::new(
move |event| {
if let Ok(event) = event {
// TODO: Should errors be emitted too?
let _ = on_event.send(event);
}
},
Config::default(),
)?;
for path in &resolved_paths {
watcher.watch(path, recursive_mode)?;
}
WatcherKind::Watcher(watcher)
};
let rid = webview.resources_table().add(watcher_kind);
Ok(rid)
}

7
plugins/fs/tsconfig.json Normal file
View File

@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "guest-js"
},
"include": ["guest-js/*.ts"]
}