add file.read_combined_object & update filesystem docs

This commit is contained in:
MihailRis
2024-11-05 14:33:56 +03:00
parent 6f2f365278
commit 4932fd8b4b
7 changed files with 283 additions and 200 deletions
+1 -72
View File
@@ -2,78 +2,7 @@
### *file* library
Filesystem interaction library.
```python
file.resolve(path: str) -> str
```
Function turns `entry_point:path` (example `user:worlds/house1`) to a regular path. (example `C://Users/user/.voxeng/worlds/house1`)
> [!NOTE]
> The function should be used for debug only. *entry_point:path* notation is required in all **file** functions.
Resulting path is not canonical and may be relative.
```python
file.read(path: str) -> str
```
Read whole text file.
```python
file.read_bytes(path: str) -> array of integers
```
Read file into bytes array.
```python
file.write(path: str, text: str) -> nil
```
Overwrite text file.
```python
file.write_bytes(path: str, data: array of integers)
```
Overwrite binary file with bytes array.
```python
file.length(path: str) -> int
```
Get file length (bytes) or 0.
```python
file.exists(path: str) -> bool
```
Check if file or directory exist.
```python
file.isfile(path: str) -> bool
```
Check if the path points to a file.
```python
file.isdir(path: str) -> bool
```
Check if the path points to a directory.
```python
file.mkdir(path: str) -> bool
```
Create directory. Returns true if new directory created
```python
file.mkdirs(path: str) -> bool
```
Create directories chain. Returns true if new directory created.
See [file library](builtins/libfile.md)
## *json* library