fs
Lite 文件访问由宿主管理。跨 Space 文件读取需 workspace.files,写入还需贡献点的 write 权限。文本读取限制 2 MiB,二进制 I/O 限制 16 MiB。getUrl 提供流式媒体地址。直接修改已打开的工作副本会返回 BUSY,rename 遇到已有目标会返回 ALREADY_EXISTS。
签名、参数及返回类型从 SDK 自动生成;可选成员不保证在每个宿主和上下文中存在。
PluginFileSystem
Section titled “PluginFileSystem”PluginFileSystem.readText
Section titled “PluginFileSystem.readText”支持宿主: Lite Mobile
读取文件文本,上限 2 MiB。
readText(path: string): Promise<string>;| 参数 | 类型 | 必填 |
|---|---|---|
path |
string |
是 |
返回值: Promise<string>.
PluginFileSystem.writeText
Section titled “PluginFileSystem.writeText”支持宿主: Lite Mobile
写入文本,按需创建父目录。
writeText(path: string, content: string): Promise<void>;| 参数 | 类型 | 必填 |
|---|---|---|
path |
string |
是 |
content |
string |
是 |
返回值: Promise<void>.
PluginFileSystem.readBinary
Section titled “PluginFileSystem.readBinary”支持宿主: Lite Mobile
读取文件字节,上限 16 MiB。
readBinary(path: string): Promise<Uint8Array>;| 参数 | 类型 | 必填 |
|---|---|---|
path |
string |
是 |
返回值: Promise<Uint8Array>.
PluginFileSystem.writeBinary
Section titled “PluginFileSystem.writeBinary”支持宿主: Lite
写入文件字节,上限 16 MiB。
writeBinary(path: string, content: Uint8Array): Promise<void>;| 参数 | 类型 | 必填 |
|---|---|---|
path |
string |
是 |
content |
Uint8Array |
是 |
返回值: Promise<void>.
PluginFileSystem.delete
Section titled “PluginFileSystem.delete”支持宿主: Lite
删除有权限的文件,已打开的工作副本受 BUSY 保护。
delete(path: string): Promise<void>;| 参数 | 类型 | 必填 |
|---|---|---|
path |
string |
是 |
返回值: Promise<void>.
PluginFileSystem.rename
Section titled “PluginFileSystem.rename”支持宿主: Lite
在 Space 内移动普通文件,目标已存在时返回 ALREADY_EXISTS。
rename(oldPath: string, newPath: string): Promise<void>;| 参数 | 类型 | 必填 |
|---|---|---|
oldPath |
string |
是 |
newPath |
string |
是 |
返回值: Promise<void>.
PluginFileSystem.list
Section titled “PluginFileSystem.list”支持宿主: Lite Mobile
列出有权限的文件,默认递归且仅包含文件;目录树使用 includeDirectories。
list(folder?: string, options?: FileListOptions): Promise<FileStat[]>;| 参数 | 类型 | 必填 |
|---|---|---|
folder |
string |
否 |
options |
FileListOptions |
否 |
返回值: Promise<FileStat[]>.
PluginFileSystem.stat
Section titled “PluginFileSystem.stat”支持宿主: Lite Mobile
读取文件元数据,不存在时返回 null。
stat(path: string): Promise<FileStat | null>;| 参数 | 类型 | 必填 |
|---|---|---|
path |
string |
是 |
返回值: Promise<FileStat | null>.
PluginFileSystem.getUrl
Section titled “PluginFileSystem.getUrl”支持宿主: Lite
获取流式媒体地址,在支持的绑定文件上下文中可省略 path。
getUrl(path?: string): Promise<string>;| 参数 | 类型 | 必填 |
|---|---|---|
path |
string |
否 |
返回值: Promise<string>.
PluginFileSystem.watch
Section titled “PluginFileSystem.watch”支持宿主: Lite Mobile
订阅文件或目录变化,使用结束后释放返回的订阅。
watch(pathOrFolder: string, listener: () => void): Promise<Disposable>;| 参数 | 类型 | 必填 |
|---|---|---|
pathOrFolder |
string |
是 |
listener |
() => void |
是 |
返回值: Promise<Disposable>.
关联类型: FileListOptions, FileStat, Disposable.