Skip to content

docs: add file.abs and file.exists documents #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/reference/model/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 100

## read

`read(filepath: string) -> str`
`read(filepath: str) -> str`

Read the contents of the file `filepath` and return a string instance.

Expand All @@ -29,3 +29,15 @@ Return the root path of the current KCL module (kcl.mod file path or single \*.k
`workdir() -> str`

Return the path of the current working directory.

## exists

`exists(filepath: str) -> bool`

Whether this file path exists. Returns true if the path points at an existing entity. This function will traverse symbolic links to query information about the destination file.

## abs

`abs(filepath: str) -> str`

Returns the canonical, absolute form of the path with all intermediate components normalized and symbolic links resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 100

## read

`read(filepath: string) -> str`
`read(filepath: str) -> str`

读取文件 `filepath` 中的内容,并返回一个字符串实例。

Expand All @@ -29,3 +29,15 @@ weight: 100
`workdir() -> str`

返回当前工作目录的路径。

## exists

`exists(filepath: str) -> bool`

判断文件路径是否存在。如果路径指向一个存在的实体,则返回 True。此函数会遍历符号链接以查询目标文件的信息。

## abs

`abs(filepath: str) -> str`

返回路径的规范化绝对形式,其中所有中间路径均已规范化并解析为符号链接。