1876 lines
50 KiB
Markdown
1876 lines
50 KiB
Markdown
# Builtin - 文件
|
||
|
||
## `createDir(alias, dir_name)`
|
||
|
||
声明:function
|
||
|
||
创建目录。目录已存在时返回假
|
||
|
||
<!-- tags: 文件 创建 生成 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ---------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `dir_name` | string | 目录名称。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
ok := createDir("", "example-dir");
|
||
removed := removeDir("", "example-dir");
|
||
echo ok and removed, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `createlink(link_name, target_name, hard)`
|
||
|
||
声明:function
|
||
|
||
创建一个目标为TargetName名为LinkName的链接。在Linux系统中用的较多
|
||
|
||
<!-- tags: 文件 创建 生成 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------------- | ------ | -------------------------------------------------------------------- |
|
||
| `link_name` | string | 字符串,指定链接生成的路径及连接名。无路径时默认生成在天软安装目录。 |
|
||
| `target_name` | string | 字符串,文件路径。 |
|
||
| `hard` | bool | 布尔值,为真表示创建硬链接,否则创建软链接(符号链接)。 |
|
||
|
||
返回:bool
|
||
|
||
### 示例
|
||
|
||
范例01:创建指向相对目标的软链接
|
||
|
||
```tsl
|
||
ok := createlink("example-link", "example-target", 0);
|
||
echo ok, "\n";
|
||
```
|
||
|
||
## `exportFile(_type, alias, file_name, data, include_header, include_index)`
|
||
|
||
声明:function
|
||
|
||
将数据导出为文件。支持将INF以及NAN导出到Excel,INF对应为EXCEL的DIV0,NAN对应为NA
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file INF NAN EXCEL DIV0 NA -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ---------------- | ------- | ---- |
|
||
| `_type` | integer | |
|
||
| `alias` | string | |
|
||
| `file_name` | string | |
|
||
| `data` | any | |
|
||
| `include_header` | | |
|
||
| `include_index` | bool | |
|
||
|
||
返回:bool|string
|
||
|
||
### 示例
|
||
|
||
范例01:将数组导出为当前目录中的 CSV 文件
|
||
|
||
```tsl
|
||
data := array(("name": "Tinysoft", "value": 1));
|
||
ok := exportFile(ftCsv(), "", "export-example.csv", data);
|
||
echo ok, "\n";
|
||
```
|
||
|
||
## `fileAge(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
获取文件的时间数值
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "age.txt", pos, 1, "x");
|
||
echo fileAge("", "age.txt") > 0, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileAttr(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
获取文件属性数值
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "attr.txt", pos, 1, "x");
|
||
echo fileAttr("", "attr.txt") >= 0, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileAttrToStr(attr)`
|
||
|
||
声明:function
|
||
|
||
文件属性数值转换成文件属性字符串。仅NG客户端中支持
|
||
|
||
<!-- tags: 文件 转换 编码 目录 路径 file NG -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------ | ------- | ------------ |
|
||
| `attr` | integer | 文件属性数值 |
|
||
|
||
返回:string
|
||
|
||
### 示例
|
||
|
||
范例01:将文件属性值转换为字符串
|
||
|
||
```tsl
|
||
attr := fileAttr("", "file-attr-example.txt");
|
||
echo fileAttrToStr(attr), "\n";
|
||
```
|
||
|
||
## `fileCopy(src_alias, src_name, dest_alias, dest_name[, fail_if_exists])`
|
||
|
||
声明:function
|
||
|
||
复制文件。目标目录必须存在
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ---------------- | ------- | ------------------------------------ |
|
||
| `src_alias` | string | 源目录别名。 |
|
||
| `src_name` | string | 源文件名称。 |
|
||
| `dest_alias` | string | 目标目录别名。 |
|
||
| `dest_name` | string | 目标文件名称。 |
|
||
| `fail_if_exists` | boolean | 目标已存在时是否返回失败;缺省为假。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "copy-source.txt", pos, 1, "x");
|
||
ok := fileCopy("", "copy-source.txt", "", "copy-dest.txt", false);
|
||
echo ok and fileExists("", "copy-dest.txt"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileDelete(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
删除文件
|
||
|
||
<!-- tags: 文件 删除 移除 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "delete.txt", pos, 1, "x");
|
||
echo fileDelete("", "delete.txt"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileExists(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
判断文件是否存在
|
||
|
||
<!-- tags: 文件 判断 检查 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "exists.txt", pos, 1, "x");
|
||
echo fileExists("", "exists.txt"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileInfo(alias, name)`
|
||
|
||
声明:function
|
||
|
||
获取文件的基本信息
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `name` | string | 路径或文件名称。 |
|
||
|
||
返回:array
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "info.txt", pos, 1, "x");
|
||
echo ifarray(fileInfo("", "info.txt")), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileList(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
列出目录中匹配文件名或通配符的文件
|
||
|
||
<!-- tags: 文件 列出 列表 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:tablearray
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "list.txt", pos, 1, "x");
|
||
echo ifarray(fileList("", "*.txt")), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileMode(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
获取文件模式数值
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "mode.txt", pos, 1, "x");
|
||
echo fileMode("", "mode.txt") > 0, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileModeToStr(mode)`
|
||
|
||
声明:function
|
||
|
||
文件模式数值转换成文件模式字符串。仅NG客户端中支持
|
||
|
||
<!-- tags: 文件 转换 编码 目录 路径 file NG -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------ | ------- | ------------ |
|
||
| `mode` | integer | 文件模式数值 |
|
||
|
||
返回:string
|
||
|
||
### 示例
|
||
|
||
范例01:将文件模式值转换为字符串
|
||
|
||
```tsl
|
||
mode := fileMode("", "file-mode-example.txt");
|
||
echo fileModeToStr(mode), "\n";
|
||
```
|
||
|
||
## `fileMove(src_alias, src_name, dest_alias, dest_name[, flag])`
|
||
|
||
声明:function
|
||
|
||
移动文件;flag 为 1 时允许覆盖,2 时允许跨卷复制,3 同时启用两者
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------------ | ------- | -------------- |
|
||
| `src_alias` | string | 源目录别名。 |
|
||
| `src_name` | string | 源文件名称。 |
|
||
| `dest_alias` | string | 目标目录别名。 |
|
||
| `dest_name` | string | 目标文件名称。 |
|
||
| `flag` | integer | 可选标志值。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "move-source.txt", pos, 1, "x");
|
||
ok := fileMove("", "move-source.txt", "", "move-dest.txt");
|
||
echo ok and fileExists("", "move-dest.txt"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileRename(alias, file_name, new_name)`
|
||
|
||
声明:function
|
||
|
||
修改文件名,也可在同一文件系统内移动文件
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `new_name` | string | 新文件名称。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "rename-source.txt", pos, 1, "x");
|
||
ok := fileRename("", "rename-source.txt", "rename-dest.txt");
|
||
echo ok and fileExists("", "rename-dest.txt"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `fileSize(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
获取文件大小
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "size.txt", pos, 5, "hello");
|
||
echo fileSize("", "size.txt"), "\n";
|
||
// 输出:5
|
||
```
|
||
|
||
## `fileTime(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
获取文件最后更新时间
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:datetime
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "time.txt", pos, 1, "x");
|
||
echo fileTime("", "time.txt") > 0, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `ftCsv()`
|
||
|
||
声明:function
|
||
|
||
逗号分割文件类型
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取 CSV 文件类型值
|
||
|
||
```tsl
|
||
echo ftCsv(), "\n";
|
||
```
|
||
|
||
## `ftdbf()`
|
||
|
||
声明:function
|
||
|
||
dbf文件类型
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取 DBF 文件类型值
|
||
|
||
```tsl
|
||
echo ftdbf(), "\n";
|
||
```
|
||
|
||
## `ftStream()`
|
||
|
||
声明:function
|
||
|
||
天软对象流文件类型
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取对象流文件类型值
|
||
|
||
```tsl
|
||
echo ftStream(), "\n";
|
||
```
|
||
|
||
## `ftString()`
|
||
|
||
声明:function
|
||
|
||
天软对象字符串文件类型
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取对象字符串文件类型值
|
||
|
||
```tsl
|
||
echo ftString(), "\n";
|
||
```
|
||
|
||
## `ftXls()`
|
||
|
||
声明:function
|
||
|
||
Excel文件类型。默认会打开EXCEL来读写文件,如果EXCEL未安装,会尝试用文件读写的模式来访问
|
||
|
||
<!-- tags: 文件 目录 路径 file EXCEL -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取 Excel 文件类型值
|
||
|
||
```tsl
|
||
echo ftXls(), "\n";
|
||
```
|
||
|
||
## `ftXls2()`
|
||
|
||
声明:function
|
||
|
||
支持多表头的Excel文件类型
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取多表头 Excel 文件类型值
|
||
|
||
```tsl
|
||
echo ftXls2(), "\n";
|
||
```
|
||
|
||
## `ftXls3()`
|
||
|
||
声明:function
|
||
|
||
Excel文件类型,默认采用文件读写的方式访问,效率高,兼容性稍差,当文件读写的模式无法正确访问,会打开EXCEL来读写文件
|
||
|
||
<!-- tags: 文件 目录 路径 file EXCEL -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取文件模式 Excel 类型值
|
||
|
||
```tsl
|
||
echo ftXls3(), "\n";
|
||
```
|
||
|
||
## `ftXml()`
|
||
|
||
声明:function
|
||
|
||
XML文件类型
|
||
|
||
<!-- tags: 文件 目录 路径 file XML -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取 XML 文件类型值
|
||
|
||
```tsl
|
||
echo ftXml(), "\n";
|
||
```
|
||
|
||
## `getDeviceFree(alias, name)`
|
||
|
||
声明:function
|
||
|
||
获取路径所在设备的剩余空间信息
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `name` | string | 路径或文件名称。 |
|
||
|
||
返回:array
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
echo ifarray(getDeviceFree("", ".")), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `getDeviceInfo(alias, name)`
|
||
|
||
声明:function
|
||
|
||
获取路径所在设备的空间等信息
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `name` | string | 路径或文件名称。 |
|
||
|
||
返回:array
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
echo ifarray(getDeviceInfo("", ".")), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `getlogicdrive()`
|
||
|
||
声明:function
|
||
|
||
获取本地逻辑驱动器
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取本地逻辑驱动器位图
|
||
|
||
```tsl
|
||
echo getlogicdrive(), "\n";
|
||
```
|
||
|
||
## `importFile(_type, alias, file_name, data, include_header, include_index, force_single, sheet_name)`
|
||
|
||
声明:function
|
||
|
||
从文件中导入数据。对EXCEL文件自动识别.xls或者.xlsx的文件格式,支持将INF以及NAN导入
|
||
|
||
<!-- tags: 文件 目录 路径 file EXCEL INF NAN -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ---------------- | ------- | ---- |
|
||
| `_type` | integer | |
|
||
| `alias` | | |
|
||
| `file_name` | string | |
|
||
| `data` | array | |
|
||
| `include_header` | | |
|
||
| `include_index` | | |
|
||
| `force_single` | bool | |
|
||
| `sheet_name` | | |
|
||
|
||
返回:bool
|
||
|
||
### 示例
|
||
|
||
范例01:导入当前脚本生成的 CSV 文件
|
||
|
||
```tsl
|
||
source_data := array(("name": "Tinysoft", "value": 1));
|
||
exportFile(ftCsv(), "", "import-example.csv", source_data);
|
||
ok := importFile(ftCsv(), "", "import-example.csv", imported_data);
|
||
echo ok, ":", toStn(imported_data), "\n";
|
||
```
|
||
|
||
## `iniDeleteKey(alias, file_name, section, ident)`
|
||
|
||
声明:function
|
||
|
||
删除INI中的标识符
|
||
|
||
<!-- tags: 文件 删除 移除 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | ----------------------------------- |
|
||
| `alias` | string | 字符串类型。目录名称 |
|
||
| `file_name` | string | 字符串类型。INI文件名称 |
|
||
| `section` | string | 字符串类型。INI文件中的节名称 |
|
||
| `ident` | string | 字符串类型。INI文件中要删除的键名称 |
|
||
|
||
返回:any
|
||
|
||
### 示例
|
||
|
||
范例01:删除当前脚本写入的 INI 键
|
||
|
||
```tsl
|
||
iniWriteString("", "example.ini", "example", "value", "Tinysoft");
|
||
result := iniDeleteKey("", "example.ini", "example", "value");
|
||
echo result, "\n";
|
||
```
|
||
|
||
## `iniEraseSection(alias, file_name, section)`
|
||
|
||
声明:function
|
||
|
||
删除 INI 文件中的节
|
||
|
||
<!-- tags: 文件 删除 移除 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteString("", "erase.ini", "example", "key", "value");
|
||
result := iniEraseSection("", "erase.ini", "example");
|
||
echo result = 0 and not iniSectionExists("", "erase.ini", "example"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadBinaryStream(alias, file_name, section, ident[, type])`
|
||
|
||
声明:function
|
||
|
||
读取 INI 中以数据流形式保存的值
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | --------------- | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `type` | integer\|stream | 可选返回类型。 |
|
||
|
||
返回:string|integer|array|binary
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteBinaryStream("", "binary.ini", "example", "key", "hello");
|
||
value := iniReadBinaryStream("", "binary.ini", "example", "key");
|
||
echo ifarray(value), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadBool(alias, file_name, section, ident, default)`
|
||
|
||
声明:function
|
||
|
||
读取 INI 布尔值;键不存在时返回 default
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------- | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `default` | boolean | 键不存在时返回的缺省值。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteBool("", "bool.ini", "example", "key", true);
|
||
echo iniReadBool("", "bool.ini", "example", "key", false), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadDate(alias, file_name, section, ident, default)`
|
||
|
||
声明:function
|
||
|
||
读取 INI 日期值
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `default` | date | 键不存在时返回的缺省日期。 |
|
||
|
||
返回:date
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteDate("", "date.ini", "example", "key", 41651);
|
||
echo iniReadDate("", "date.ini", "example", "key", 0) = 41651, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadDateTime(alias, file_name, section, ident, default)`
|
||
|
||
声明:function
|
||
|
||
读取 INI 日期时间值
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | -------- | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `default` | datetime | 键不存在时返回的缺省日期时间。 |
|
||
|
||
返回:datetime
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteDateTime("", "datetime.ini", "example", "key", 41651.5);
|
||
echo iniReadDateTime("", "datetime.ini", "example", "key", 0) = 41651.5, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadFloat(alias, file_name, section, ident, default)`
|
||
|
||
声明:function
|
||
|
||
读取 INI 浮点值
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `default` | real | 键不存在时返回的缺省浮点值。 |
|
||
|
||
返回:real
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteFloat("", "float.ini", "example", "key", 1.25);
|
||
echo iniReadFloat("", "float.ini", "example", "key", 0) = 1.25, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadInteger(alias, file_name, section, ident, default)`
|
||
|
||
声明:function
|
||
|
||
读取 INI 整数值
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------- | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `default` | integer | 键不存在时返回的缺省整数。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteInteger("", "integer.ini", "example", "key", 42);
|
||
echo iniReadInteger("", "integer.ini", "example", "key", 0), "\n";
|
||
// 输出:42
|
||
```
|
||
|
||
## `iniReadSection(alias, file_name, section)`
|
||
|
||
声明:function
|
||
|
||
读取指定节中的键名列表
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
|
||
返回:array of string
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteString("", "section.ini", "example", "key", "value");
|
||
echo ifarray(iniReadSection("", "section.ini", "example")), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadSections(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
读取 INI 文件中的节名列表
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:array of string
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteString("", "sections.ini", "example", "key", "value");
|
||
echo ifarray(iniReadSections("", "sections.ini")), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadSectionsw(alias, file_name)`
|
||
|
||
声明:function
|
||
|
||
以宽字节形式读取 INI 文件中的节名列表
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
|
||
返回:array of string
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteString("", "sectionsw.ini", "example", "key", "value");
|
||
echo ifarray(iniReadSectionsw("", "sectionsw.ini")), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadSectionValues(alias, file_name, section)`
|
||
|
||
声明:function
|
||
|
||
读取指定节中的键值列表
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
|
||
返回:array of string
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteString("", "section-values.ini", "example", "key", "value");
|
||
echo ifarray(iniReadSectionValues("", "section-values.ini", "example")), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniReadString(alias, file_name, section, ident, default)`
|
||
|
||
声明:function
|
||
|
||
读取 INI 字符串值
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `default` | string | 键不存在时返回的缺省字符串。 |
|
||
|
||
返回:string
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteString("", "string.ini", "example", "key", "Tinysoft");
|
||
echo iniReadString("", "string.ini", "example", "key", ""), "\n";
|
||
// 输出:Tinysoft
|
||
```
|
||
|
||
## `iniReadTime(alias, file_name, section, ident, default)`
|
||
|
||
声明:function
|
||
|
||
读取 INI 时间值
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `default` | time | 键不存在时返回的缺省时间。 |
|
||
|
||
返回:time
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteTime("", "time.ini", "example", "key", 0.5);
|
||
echo iniReadTime("", "time.ini", "example", "key", 0) = 0.5, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniSectionExists(alias, file_name, section)`
|
||
|
||
声明:function
|
||
|
||
判断 INI 节是否存在
|
||
|
||
<!-- tags: 文件 判断 检查 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteString("", "exists.ini", "example", "key", "value");
|
||
echo iniSectionExists("", "exists.ini", "example"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniValueExists(alias, file_name, section, ident)`
|
||
|
||
声明:function
|
||
|
||
判断 INI 节中的键是否存在
|
||
|
||
<!-- tags: 文件 判断 检查 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteString("", "value-exists.ini", "example", "key", "value");
|
||
echo iniValueExists("", "value-exists.ini", "example", "key"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniWriteBinaryStream(alias, file_name, section, ident, value)`
|
||
|
||
声明:function
|
||
|
||
将字符串、数组或二进制值写入 INI 数据流
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------------------------------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `section` | string | INI 节名。 |
|
||
| `ident` | string | INI 键名。 |
|
||
| `value` | string\|integer\|array\|binary | 要写入的数据。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
iniWriteBinaryStream("", "write-binary.ini", "example", "key", "hello");
|
||
value := iniReadBinaryStream("", "write-binary.ini", "example", "key");
|
||
echo ifarray(value), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `iniWriteBool(alias, file_name, section, ident, value)`
|
||
|
||
声明:function
|
||
|
||
将BOOL值写入INI。如果不存在FileName,或者不存在Section,或者不存在Ident,则其会根据输入的FileName,Section,Ident创建对应的INI文件,INI文件的节名称,INI文件的键名称,并将Bool值Value写入到INI文件指定的键
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file BOOL INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | --------------------------- |
|
||
| `alias` | string | 字符串类型。目录名称 |
|
||
| `file_name` | string | 字符串类型。INI文件名称 |
|
||
| `section` | string | 字符串类型。INI文件的节名称 |
|
||
| `ident` | string | 字符串类型。INI文件的键名称 |
|
||
| `value` | bool | 布尔类型。要写入的键值 |
|
||
|
||
返回:any
|
||
|
||
### 示例
|
||
|
||
范例01:写入布尔值到当前目录中的 INI 文件
|
||
|
||
```tsl
|
||
result := iniWriteBool("", "example.ini", "example", "value", 1);
|
||
echo result, "\n";
|
||
```
|
||
|
||
## `iniWriteDate(alias, file_name, section, ident, value)`
|
||
|
||
声明:function
|
||
|
||
将日期值写入INI。如果不存在FileName,或者不存在Section,或者不存在Ident,则其会根据输入的FileName,Section,Ident创建对应的INI文件,INI文件的节名称,INI文件的键名称,并将日期值Value写入到INI文件指定的键
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | --------------------------- |
|
||
| `alias` | string | 字符串类型。目录名称 |
|
||
| `file_name` | string | 字符串类型。INI文件名称 |
|
||
| `section` | string | 字符串类型。INI文件的节名称 |
|
||
| `ident` | string | 字符串类型。INI文件的键名称 |
|
||
| `value` | tdate | 日期类型。要写入的日期值 |
|
||
|
||
返回:any
|
||
|
||
### 示例
|
||
|
||
范例01:写入日期值到当前目录中的 INI 文件
|
||
|
||
```tsl
|
||
result := iniWriteDate("", "example.ini", "example", "value", 41651);
|
||
echo result, "\n";
|
||
```
|
||
|
||
## `iniWriteDateTime(alias, file_name, section, ident, value)`
|
||
|
||
声明:function
|
||
|
||
将日期时间值写入INI。如果不存在FileName,或者不存在Section,或者不存在Ident,则其会根据输入的FileName,Section,Ident创建对应的INI文件,INI文件的节名称,INI文件的键名称,并将日期时间值Value写入到INI文件指定的键
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | --------- | -------------------------------- |
|
||
| `alias` | string | 字符串类型。目录名称 |
|
||
| `file_name` | string | 字符串类型。INI文件名称 |
|
||
| `section` | string | 字符串类型。INI文件的节名称 |
|
||
| `ident` | string | 字符串类型。INI文件的键名称 |
|
||
| `value` | tdatetime | 日期时间类型。要写入的日期时间值 |
|
||
|
||
返回:any
|
||
|
||
### 示例
|
||
|
||
范例01:写入日期时间值到当前目录中的 INI 文件
|
||
|
||
```tsl
|
||
result := iniWriteDateTime("", "example.ini", "example", "value", 41651.5);
|
||
echo result, "\n";
|
||
```
|
||
|
||
## `iniWriteFloat(alias, file_name, section, ident, value)`
|
||
|
||
声明:function
|
||
|
||
将浮点值写入INI。如果不存在FileName,或者不存在Section,或者不存在Ident,则其会根据输入的FileName,Section,Ident创建对应的INI文件,INI文件的节名称,INI文件的键名称,并将浮点值Value写入到INI文件指定的键
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | --------------------------- |
|
||
| `alias` | string | 字符串类型。目录名称 |
|
||
| `file_name` | string | 字符串类型。INI文件名称 |
|
||
| `section` | string | 字符串类型。INI文件的节名称 |
|
||
| `ident` | string | 字符串类型。INI文件的键名称 |
|
||
| `value` | real | 浮点类型。要写入的浮点数值 |
|
||
|
||
返回:any
|
||
|
||
### 示例
|
||
|
||
范例01:写入浮点值到当前目录中的 INI 文件
|
||
|
||
```tsl
|
||
result := iniWriteFloat("", "example.ini", "example", "value", 9.9);
|
||
echo result, "\n";
|
||
```
|
||
|
||
## `iniWriteInteger(alias, file_name, section, ident, value)`
|
||
|
||
声明:function
|
||
|
||
将整数值写入INI。如果不存在FileName,或者不存在Section,或者不存在Ident,则其会根据输入的FileName,Section,Ident创建对应的INI文件,INI文件的节名称,INI文件的键名称,并将整数值Value写入到INI文件指定的键
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------- | --------------------------- |
|
||
| `alias` | string | 字符串类型。目录名称 |
|
||
| `file_name` | string | 字符串类型。INI文件名称 |
|
||
| `section` | string | 字符串类型。INI文件的节名称 |
|
||
| `ident` | string | 字符串类型。INI文件的键名称 |
|
||
| `value` | integer | 整数类型。要写入的整数值 |
|
||
|
||
返回:any
|
||
|
||
### 示例
|
||
|
||
范例01:写入整数值到当前目录中的 INI 文件
|
||
|
||
```tsl
|
||
result := iniWriteInteger("", "example.ini", "example", "value", 100);
|
||
echo result, "\n";
|
||
```
|
||
|
||
## `iniWriteString(alias, file_name, section, ident, value)`
|
||
|
||
声明:function
|
||
|
||
将字符串值写入INI。如果不存在FileName,或者不存在Section,或者不存在Ident,则其会根据输入的FileName,Section,Ident创建对应的INI文件,INI文件的节名称,INI文件的键名称,并将字符串Value写入到INI文件指定的键
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | --------------------------- |
|
||
| `alias` | string | 字符串类型。目录名称 |
|
||
| `file_name` | string | 字符串类型。INI文件名称 |
|
||
| `section` | string | 字符串类型。INI文件的节名称 |
|
||
| `ident` | string | 字符串类型。INI文件的键名称 |
|
||
| `value` | string | 字符串类型。要写入的字符串 |
|
||
|
||
返回:any
|
||
|
||
### 示例
|
||
|
||
范例01:写入字符串值到当前目录中的 INI 文件
|
||
|
||
```tsl
|
||
result := iniWriteString("", "example.ini", "example", "value", "Tinysoft");
|
||
echo result, "\n";
|
||
```
|
||
|
||
## `iniWriteTime(alias, file_name, section, ident, value)`
|
||
|
||
声明:function
|
||
|
||
将时间值写入INI。如果不存在FileName,或者不存在Section,或者不存在Ident,则其会根据输入的FileName,Section,Ident创建对应的INI文件,INI文件的节名称,INI文件的键名称,并将时间值Value写入到INI文件指定的键
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file INI -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------ | --------------------------- |
|
||
| `alias` | string | 字符串类型。目录名称 |
|
||
| `file_name` | string | 字符串类型。INI文件名称 |
|
||
| `section` | string | 字符串类型。INI文件的节名称 |
|
||
| `ident` | string | 字符串类型。INI文件的键名称 |
|
||
| `value` | ttime | 时间类型。要写入的时间值 |
|
||
|
||
返回:any
|
||
|
||
### 示例
|
||
|
||
范例01:写入时间值到当前目录中的 INI 文件
|
||
|
||
```tsl
|
||
result := iniWriteTime("", "example.ini", "example", "value", 0.5);
|
||
echo result, "\n";
|
||
```
|
||
|
||
## `pluginPath()`
|
||
|
||
声明:function
|
||
|
||
获取解析器的插件目录的全路径(包含名称)。当在WORD里或者EXCEL使用TSL程序的时候,由于宿主程序是WORD,解释器的路径并不在SysExecName下,那么PluginPath的父目录就是解释器的路径
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file WORD EXCEL -->
|
||
|
||
返回:string
|
||
|
||
### 示例
|
||
|
||
范例01:读取当前插件目录
|
||
|
||
```tsl
|
||
echo pluginPath(), "\n";
|
||
```
|
||
|
||
## `rarExtract(rar_alias, rar_filename, alias, path, password)`
|
||
|
||
声明:function
|
||
|
||
将RAR文件解压到指定目录
|
||
|
||
<!-- tags: 文件 目录 路径 file RAR -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| -------------- | ------ | -------------------------- |
|
||
| `rar_alias` | string | 字符串 ,RAR文件的目录别名 |
|
||
| `rar_filename` | string | 字符串 ,RAR文件名称 |
|
||
| `alias` | string | 字符串,文件解压目录别名 |
|
||
| `path` | string | 字符串,文件解压路径 |
|
||
| `password` | string | 可选。字符串,加密密码 |
|
||
|
||
返回:bool
|
||
|
||
### 示例
|
||
|
||
范例01:尝试解压指定 RAR 文件
|
||
|
||
```tsl
|
||
// 运行前将 example.rar 放到当前目录。
|
||
ok := rarExtract("", "example.rar", "", "rar-output", "");
|
||
echo ok, "\n";
|
||
```
|
||
|
||
## `readFile(data_type, alias, file_name, pos, length, data)`
|
||
|
||
声明:function
|
||
|
||
将本地的文件读取出来。文件格式可以是字符流、整数流、实数流、字节流等
|
||
|
||
<!-- tags: 文件 读取 获取 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||
| `data_type` | integer | 整数类型。参考文件读写类型函数。 |
|
||
| `alias` | string | 字符串类型。参考目录别名。 |
|
||
| `file_name` | string | 字符串类型。文件名称。 |
|
||
| `pos` | integer | 整数类型。读文件的偏移位置,执行结束后将返回新的位置。 |
|
||
| `length` | integer | 整数类型。需要读入的数据长度,一次读取的最大长度为100w。 |
|
||
| `data` | | 当读文件执行出错,则存贮错误信息,如果执行正确,则用来存贮读出的数据。如果文件类型为rwRaw或者rwBinary则返回一个长度为Length的字符串或者二进制流,否则,返回一个长度为Length的数组。例如类型为rwReal就是返回一个实数数组。 |
|
||
|
||
返回:bool
|
||
|
||
### 示例
|
||
|
||
范例01:读取当前目录中的临时 INI 文件
|
||
|
||
```tsl
|
||
iniWriteString("", "read-file-example.ini", "example", "name", "Tinysoft");
|
||
file_size := fileSize("", "read-file-example.ini");
|
||
ok := readFile(rwRaw(), "", "read-file-example.ini", 0, file_size, file_data);
|
||
echo ok, "\n";
|
||
```
|
||
|
||
## `realpath(name)`
|
||
|
||
声明:function
|
||
|
||
获取文件真实路径与名称。如果是链接类型文件,或者所处在一个链接目录中,可以得到该文件的真实存贮位置。在Windows上,返回的是一个UNC名称
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file UNC -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------ | ------ | ---------------------------- |
|
||
| `name` | string | 字符串,文件路径或链接别名。 |
|
||
|
||
返回:string
|
||
|
||
### 示例
|
||
|
||
范例01:读取当前目录的真实路径
|
||
|
||
```tsl
|
||
echo realpath("."), "\n";
|
||
```
|
||
|
||
## `removeDir(alias, dir_name)`
|
||
|
||
声明:function
|
||
|
||
删除空目录
|
||
|
||
<!-- tags: 文件 删除 移除 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ---------- | ------ | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `dir_name` | string | 目录名称。 |
|
||
|
||
返回:boolean
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
createDir("", "remove-dir");
|
||
echo removeDir("", "remove-dir"), "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `rwBinary()`
|
||
|
||
声明:function
|
||
|
||
二进制读写类型。读/写指定长度的字节流。读写的操作使用Binary数据类型
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取二进制流类型值
|
||
|
||
```tsl
|
||
echo rwBinary(), "\n";
|
||
```
|
||
|
||
## `rwByte()`
|
||
|
||
声明:function
|
||
|
||
字节流读写类型。读/写字节数组
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取字节流类型值
|
||
|
||
```tsl
|
||
echo rwByte(), "\n";
|
||
```
|
||
|
||
## `rwInt()`
|
||
|
||
声明:function
|
||
|
||
整数流读写类型。读/写整数数组
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取整数流类型值
|
||
|
||
```tsl
|
||
echo rwInt(), "\n";
|
||
```
|
||
|
||
## `rwObj()`
|
||
|
||
声明:function
|
||
|
||
对象流读写类型。读/写对象数组
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取对象流类型值
|
||
|
||
```tsl
|
||
echo rwObj(), "\n";
|
||
```
|
||
|
||
## `rwRaw()`
|
||
|
||
声明:function
|
||
|
||
原始读写类型。读/写指定长度的字节流
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取原始流类型值
|
||
|
||
```tsl
|
||
echo rwRaw(), "\n";
|
||
```
|
||
|
||
## `rwReal()`
|
||
|
||
声明:function
|
||
|
||
实数流读写类型。读/写实数数组
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取实数流类型值
|
||
|
||
```tsl
|
||
echo rwReal(), "\n";
|
||
```
|
||
|
||
## `rwStr()`
|
||
|
||
声明:function
|
||
|
||
字符串流读写类型。读/写字符串数组
|
||
|
||
<!-- tags: 文件 目录 路径 file -->
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:读取字符串流类型值
|
||
|
||
```tsl
|
||
echo rwStr(), "\n";
|
||
```
|
||
|
||
## `setFileAge(alias, file_name, age)`
|
||
|
||
声明:function
|
||
|
||
设置文件时间数值
|
||
|
||
<!-- tags: 文件 设置 修改 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------- | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `age` | integer | 文件时间数值。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "set-age.txt", pos, 1, "x");
|
||
age := fileAge("", "set-age.txt");
|
||
setFileAge("", "set-age.txt", age);
|
||
echo fileAge("", "set-age.txt") = age, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `setFileAttr(alias, file_name, attr)`
|
||
|
||
声明:function
|
||
|
||
设置文件属性
|
||
|
||
<!-- tags: 文件 设置 修改 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------- | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `attr` | integer | 文件属性数值。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "set-attr.txt", pos, 1, "x");
|
||
attr := fileAttr("", "set-attr.txt");
|
||
result := setFileAttr("", "set-attr.txt", attr);
|
||
echo result = 0 and fileAttr("", "set-attr.txt") = attr, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `setFileMode(alias, file_name, mode)`
|
||
|
||
声明:function
|
||
|
||
设置文件模式
|
||
|
||
<!-- tags: 文件 设置 修改 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------- | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `mode` | integer | 模式数值。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "set-mode.txt", pos, 1, "x");
|
||
mode := fileMode("", "set-mode.txt");
|
||
setFileMode("", "set-mode.txt", mode);
|
||
echo fileMode("", "set-mode.txt") = mode, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `setFileTime(alias, file_name, time)`
|
||
|
||
声明:function
|
||
|
||
设置文件最后更新时间,成功返回 0
|
||
|
||
<!-- tags: 文件 设置 修改 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | -------- | -------------------------------- |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `time` | datetime | 文件日期时间。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
writeFile(rwRaw(), "", "set-time.txt", pos, 1, "x");
|
||
mtime := fileTime("", "set-time.txt");
|
||
result := setFileTime("", "set-time.txt", mtime);
|
||
echo result = 0, "\n";
|
||
// 输出:1
|
||
```
|
||
|
||
## `strToFileAttr(str)`
|
||
|
||
声明:function
|
||
|
||
文件属性字符串转换成文件属性数值。仅NG客户端中支持
|
||
|
||
<!-- tags: 文件 转换 编码 目录 路径 file NG -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----- | ------ | ---------------------------- |
|
||
| `str` | string | 字符串类型,文件属性字符串。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:将文件属性字符串转换为数值
|
||
|
||
```tsl
|
||
echo strToFileAttr("A"), "\n";
|
||
```
|
||
|
||
## `strToFileMode(str)`
|
||
|
||
声明:function
|
||
|
||
文件模式字符串转换成文件模式数值。仅NG客户端中支持
|
||
|
||
<!-- tags: 文件 转换 编码 目录 路径 file NG -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----- | ------ | ---------------------------- |
|
||
| `str` | string | 字符串类型,文件模式字符串。 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
范例01:将文件模式字符串转换为数值
|
||
|
||
```tsl
|
||
echo strToFileMode("A"), "\n";
|
||
```
|
||
|
||
## `sysClientInfo()`
|
||
|
||
声明:function
|
||
|
||
在平台应用可获得客户机信息,这些信息除了客户端收集的有限信息:包括MAC地址/IP/HOSTNAME/操作系统类型以外,还存在其他客户端的信息插件提供的内容,例如一些交易插件会收集交易需要的本地识别码
|
||
|
||
<!-- tags: 文件 目录 路径 file MAC IP HOSTNAME -->
|
||
|
||
返回:array
|
||
|
||
### 示例
|
||
|
||
范例01:读取当前客户端信息
|
||
|
||
```tsl
|
||
echo toStn(sysClientInfo()), "\n";
|
||
```
|
||
|
||
## `sysExecName()`
|
||
|
||
声明:function
|
||
|
||
获取解析器的全路径(包含名称)
|
||
|
||
<!-- tags: 文件 获取 查询 目录 路径 file -->
|
||
|
||
返回:string
|
||
|
||
### 示例
|
||
|
||
范例01:读取当前解析器路径
|
||
|
||
```tsl
|
||
echo sysExecName(), "\n";
|
||
```
|
||
|
||
## `writeFile(data_type, alias, file_name, var pos, length, data)`
|
||
|
||
声明:function
|
||
|
||
按指定文件类型写入数据;pos 为 -1 时追加到文件末尾
|
||
|
||
<!-- tags: 文件 写入 保存 目录 路径 file -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ----------- | ------- | ---------------------------------------- |
|
||
| `data_type` | integer | 文件读写类型。 |
|
||
| `alias` | string | 目录别名;空字符串表示当前目录。 |
|
||
| `file_name` | string | 文件名称。 |
|
||
| `pos` | integer | 写回读写后的文件位置;传入 -1 表示追加。 |
|
||
| `length` | integer | 写入的数据长度。 |
|
||
| `data` | any | 写入的数据。 |
|
||
|
||
返回:boolean|string
|
||
|
||
### 示例
|
||
|
||
范例01:基本用法
|
||
|
||
```tsl
|
||
pos := 0;
|
||
ok := writeFile(rwRaw(), "", "write-file.txt", pos, 5, "hello");
|
||
echo ok, ":", pos, "\n";
|
||
// 输出:1:5
|
||
```
|
||
|
||
## `zipCompress(zip_alias, zip_filename, alias, filename, path)`
|
||
|
||
声明:function
|
||
|
||
将文件压缩到ZIP文件中,如果压缩文件不存在,函数会创建一个。ZIP格式的压缩不支持加密
|
||
|
||
<!-- tags: 文件 目录 路径 file ZIP -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| -------------- | ------ | ----------------------------- |
|
||
| `zip_alias` | string | 字符串,ZIP文件的目录别名 |
|
||
| `zip_filename` | string | 字符串,ZIP文件名称 |
|
||
| `alias` | string | 字符串,被压缩文件的目录别名 |
|
||
| `filename` | string | 字符串,文件名称 |
|
||
| `path` | string | 字符串,文件在ZIP文件中的路径 |
|
||
|
||
返回:bool
|
||
|
||
### 示例
|
||
|
||
范例01:压缩当前目录中的临时文件
|
||
|
||
```tsl
|
||
iniWriteString("", "zip-source.ini", "example", "name", "Tinysoft");
|
||
ok := zipCompress("", "example.zip", "", "zip-source.ini", "zip-source.ini");
|
||
echo ok, "\n";
|
||
```
|
||
|
||
## `zipExtract(zip_alias, zip_filename, alias, path, password)`
|
||
|
||
声明:function
|
||
|
||
将ZIP文件解压到指定目录
|
||
|
||
<!-- tags: 文件 目录 路径 file ZIP -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| -------------- | ------ | -------------------------- |
|
||
| `zip_alias` | string | 字符串 ,ZIP文件的目录别名 |
|
||
| `zip_filename` | string | 字符串 ,ZIP文件名称 |
|
||
| `alias` | string | 字符串,文件解压目录别名 |
|
||
| `path` | string | 字符串,文件解压路径 |
|
||
| `password` | string | 可选。字符串,加密密码 |
|
||
|
||
返回:bool
|
||
|
||
### 示例
|
||
|
||
范例01:解压当前脚本创建的 ZIP 文件
|
||
|
||
```tsl
|
||
iniWriteString("", "zip-source.ini", "example", "name", "Tinysoft");
|
||
zipCompress("", "example.zip", "", "zip-source.ini", "zip-source.ini");
|
||
ok := zipExtract("", "example.zip", "", "zip-output", "");
|
||
echo ok, "\n";
|
||
```
|