2017-02-15 23:49:16 +08:00
|
|
|
---
|
2020-09-14 22:47:49 +08:00
|
|
|
title: "file API"
|
2018-09-25 22:09:28 +08:00
|
|
|
description: "file API provides some basic functions and values for current os."
|
2017-02-15 23:49:16 +08:00
|
|
|
---
|
|
|
|
|
2018-06-03 10:40:11 +08:00
|
|
|
# [Available APIs](../) >> file
|
|
|
|
|
|
|
|
|
|
|
|
<!-- vim-markdown-toc GFM -->
|
|
|
|
|
|
|
|
- [values](#values)
|
|
|
|
- [functions](#functions)
|
2021-08-14 14:20:03 +08:00
|
|
|
- [Usage](#usage)
|
2018-06-03 10:40:11 +08:00
|
|
|
|
|
|
|
<!-- vim-markdown-toc -->
|
2017-02-17 21:02:14 +08:00
|
|
|
|
2017-02-15 23:49:16 +08:00
|
|
|
## values
|
|
|
|
|
2018-06-03 10:40:11 +08:00
|
|
|
| name | description |
|
|
|
|
| ------------- | ---------------------------------------------- |
|
|
|
|
| separator | The system-dependent name-separator character. |
|
|
|
|
| pathSeparator | The system-dependent path-separator character. |
|
2017-02-16 23:14:23 +08:00
|
|
|
|
2017-02-15 23:49:16 +08:00
|
|
|
## functions
|
2018-06-03 10:40:11 +08:00
|
|
|
|
|
|
|
| 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 |
|
2021-08-14 14:20:03 +08:00
|
|
|
|
|
|
|
## 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)
|
|
|
|
```
|