Skip to content

Latest commit

 

History

History
938 lines (435 loc) · 11.8 KB

File metadata and controls

938 lines (435 loc) · 11.8 KB

SYS_FileSystem class

系统 / 文件系统交互类

Signature

declare class SYS_FileSystem 

Remarks

Methods

Method

Modifiers

Description

deleteFileInFileSystem(uri, force)

(BETA) 删除文件系统内的文件

getDocumentsPath()

(BETA) 获取文档目录路径

getEdaPath()

(BETA) 获取 EDA 文档目录路径

getExtensionFile(uri)

获取扩展内的文件

getLibrariesPaths()

(BETA) 获取库目录路径

getProjectsPaths()

(BETA) 获取工程目录路径

listFilesOfFileSystem(folderPath, recursive)

(BETA) 查看文件系统路径下的文件列表

openReadFileDialog(filenameExtensions, multiFiles)

(BETA) 打开读入文件窗口

openReadFileDialog(filenameExtensions, multiFiles)

(BETA) 打开读入文件窗口

readFileFromFileSystem(uri)

(BETA) 从文件系统读取文件

saveFile(fileData, fileName)

保存文件

saveFileToFileSystem(uri, fileData, fileName, force)

(BETA) 向文件系统写入文件


方法详情

deletefileinfilesystem

SYS_FileSystem.deleteFileInFileSystem() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

删除文件系统内的文件

Signature

deleteFileInFileSystem(uri: string, force?: boolean): Promise<boolean>;

Parameters

Parameter

Type

Description

uri

string

文件资源定位符

如若结尾为斜杠 /(Windows 为反斜杠 \),则识别为文件夹;

如若结尾非斜杠,则识别为完整文件名,此时 fileName 参数将被忽略

force

boolean

(Optional) 强制删除文件夹(当欲删除的是文件夹且文件夹内有文件时,是否强制删除该文件夹)

Returns

Promise<boolean>

删除操作是否成功

Remarks

注意 1:本接口仅客户端有效,在浏览器环境内调用将始终 throw Error

注意 2:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error

getdocumentspath

SYS_FileSystem.getDocumentsPath() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

获取文档目录路径

Signature

getDocumentsPath(): Promise<string>;

Returns

Promise<string>

文档目录路径

Remarks

返回的路径中,结尾不包含斜杠 /(或反斜杠 \

注意 1:本接口仅客户端有效,在浏览器环境内调用将始终 throw Error

注意 2:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error

getedapath

SYS_FileSystem.getEdaPath() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

获取 EDA 文档目录路径

Signature

getEdaPath(): Promise<string>;

Returns

Promise<string>

EDA 文档目录路径

Remarks

返回的路径中,结尾不包含斜杠 /(或反斜杠 \

注意 1:本接口仅客户端有效,在浏览器环境内调用将始终 throw Error

注意 2:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error

getextensionfile

SYS_FileSystem.getExtensionFile() method

获取扩展内的文件

Signature

getExtensionFile(uri: string): Promise<File | undefined>;

Parameters

Parameter

Type

Description

uri

string

文件路径

Returns

Promise<File | undefined>

File 格式文件

getlibrariespaths

SYS_FileSystem.getLibrariesPaths() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

获取库目录路径

Signature

getLibrariesPaths(): Promise<Array<string>>;

Returns

Promise<Array<string>>

库目录路径数组

Remarks

注意 1:本接口仅全离线客户端有效,在浏览器环境内调用将始终 throw Error

注意 2:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error

getprojectspaths

SYS_FileSystem.getProjectsPaths() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

获取工程目录路径

Signature

getProjectsPaths(): Promise<Array<string>>;

Returns

Promise<Array<string>>

工程目录路径数组

Remarks

注意 1:本接口仅半、全离线客户端有效,在浏览器环境内调用将始终 throw Error

注意 2:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error

listfilesoffilesystem

SYS_FileSystem.listFilesOfFileSystem() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

查看文件系统路径下的文件列表

Signature

listFilesOfFileSystem(folderPath: string, recursive?: boolean): Promise<Array<ISYS_FileSystemFileList>>;

Parameters

Parameter

Type

Description

folderPath

string

目录路径

recursive

boolean

(Optional) 是否递归获取所有子文件

Returns

Promise<Array<ISYS_FileSystemFileList>>

当前目录下的文件列表

Remarks

注意 1:本接口仅客户端有效,在浏览器环境内调用将始终 throw Error

注意 2:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error

openreadfiledialog

SYS_FileSystem.openReadFileDialog() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

打开读入文件窗口

Signature

openReadFileDialog(filenameExtensions?: string | Array<string>, multiFiles?: true): Promise<Array<File> | undefined>;

Parameters

Parameter

Type

Description

filenameExtensions

string | Array<string>

(Optional) 文件扩展名

multiFiles

true

(Optional) 是否允许读取多文件

Returns

Promise<Array<File> | undefined>

File 格式文件数组

openreadfiledialog_1

SYS_FileSystem.openReadFileDialog() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

打开读入文件窗口

Signature

openReadFileDialog(filenameExtensions?: string | Array<string>, multiFiles?: false): Promise<File | undefined>;

Parameters

Parameter

Type

Description

filenameExtensions

string | Array<string>

(Optional) 文件扩展名

multiFiles

false

(Optional) 是否允许读取多文件

Returns

Promise<File | undefined>

File 格式文件

readfilefromfilesystem

SYS_FileSystem.readFileFromFileSystem() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

从文件系统读取文件

Signature

readFileFromFileSystem(uri: string): Promise<File | undefined>;

Parameters

Parameter

Type

Description

uri

string

文件资源定位符,需要包含完整的文件名称的绝对路径

Returns

Promise<File | undefined>

File 格式文件

Remarks

注意 1:本接口仅客户端有效,在浏览器环境内调用将始终 throw Error

注意 2:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error

savefile

SYS_FileSystem.saveFile() method

保存文件

Signature

saveFile(fileData: File | Blob, fileName?: string): Promise<void>;

Parameters

Parameter

Type

Description

fileData

File | Blob

文件数据

fileName

string

(Optional) 文件名称

Returns

Promise<void>

Remarks

调用浏览器下载接口或 Electron 保存文件接口,将传入的文件流保存到本地

savefiletofilesystem

SYS_FileSystem.saveFileToFileSystem() method

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

向文件系统写入文件

Signature

saveFileToFileSystem(uri: string, fileData: File | Blob, fileName?: string, force?: boolean): Promise<boolean>;

Parameters

Parameter

Type

Description

uri

string

文件资源定位符

如若结尾为斜杠 /(Windows 为反斜杠 \),则识别为文件夹;

如若结尾非斜杠,则识别为完整文件名,此时 fileName 参数将被忽略

fileData

File | Blob

文件数据

fileName

string

(Optional) 文件名称

force

boolean

(Optional) 强制写入(文件存在则覆盖文件)

Returns

Promise<boolean>

写入操作是否成功,如若不允许覆盖但文件已存在将返回 false 的结果

Remarks

注意 1:本接口仅客户端有效,在浏览器环境内调用将始终 throw Error

注意 2:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error