1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-31 23:00:06 +08:00
SpaceVim/docs/api/file.md
2021-08-14 14:20:03 +08:00

52 lines
1.4 KiB
Markdown

---
title: "file API"
description: "file API provides some basic functions and values for current os."
---
# [Available APIs](../) >> file
<!-- vim-markdown-toc GFM -->
- [values](#values)
- [functions](#functions)
- [Usage](#usage)
<!-- vim-markdown-toc -->
## values
| name | description |
| ------------- | ---------------------------------------------- |
| separator | The system-dependent name-separator character. |
| pathSeparator | The system-dependent path-separator character. |
## functions
| name | description |
| ------------------------- | ----------------------------------------------- |
| `fticon(file)` | return the icon of specific file name or path |
| `write(message, file)` | append message to file |
| `override(message, file)` | override message to file |
| `read(file)` | read message from file |
| `ls(dir, if_file_only)` | list files and directorys in specific directory |
| `updateFiles(files)` | update the contents of all files |
## Usage
This api can be used in both vim script and lua script.
**vim script:**
```vim
let s:FILE = SpaceVim#api#import('file')
echom S:FILE.separator
```
**lua script:**
```lua
local file_api = require('spacevim.api').import('file')
print(file_api.separator)
```