Skip to content

Commit

Permalink
Merge pull request #321 from Peefy/file-abs-and-exists-documents
Browse files Browse the repository at this point in the history
docs: add file.abs and file.exists documents
  • Loading branch information
Peefy authored Mar 25, 2024
2 parents 1d91e72 + 2740c60 commit e580b9a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
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`

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

0 comments on commit e580b9a

Please sign in to comment.