refactor(fs)!: remove read_text_file and write_text_file commands (#3605)

`readTextFile` and `writeTextFile` now go through `read_file` and
`write_file`, so the `allow-read-text-file`, `deny-read-text-file`,
`allow-write-text-file` and `deny-write-text-file` permissions are gone;
grant `fs:allow-read-file` and `fs:allow-write-file` instead.
This commit is contained in:
Lucas Fernandes Nogueira
2026-09-22 06:04:53 -03:00
committed by GitHub
parent 120d00558e
commit 5c077a3812
13 changed files with 10 additions and 123 deletions
+2 -22
View File
@@ -781,16 +781,7 @@ async function readTextFile(
path: string | URL,
options?: ReadFileOptions
): Promise<string> {
if (path instanceof URL && path.protocol !== 'file:') {
throw new TypeError('Must be a file URL.')
}
const arr = await invoke<ArrayBuffer | number[]>('plugin:fs|read_text_file', {
path: path instanceof URL ? path.toString() : path,
options
})
const bytes = arr instanceof ArrayBuffer ? arr : Uint8Array.from(arr)
const bytes = await readFile(path, options)
return new TextDecoder(options?.encoding ?? 'utf-8').decode(bytes)
}
@@ -1138,18 +1129,7 @@ async function writeTextFile(
data: string,
options?: WriteFileOptions
): Promise<void> {
if (path instanceof URL && path.protocol !== 'file:') {
throw new TypeError('Must be a file URL.')
}
const encoder = new TextEncoder()
await invoke('plugin:fs|write_text_file', encoder.encode(data), {
headers: {
path: encodeURIComponent(path instanceof URL ? path.toString() : path),
options: JSON.stringify(options)
}
})
await writeFile(path, new TextEncoder().encode(data), options)
}
/**