获取文件的信息以及判断文件是否存在
int or str getfileinfo(str filename,int mode);
//filename: 文件名称,例如:"/a.txt"
//mode:文件信息的类型
mode类型表:
mode | 说明 | 返回值 |
---|---|---|
0 | 判断文件是否存在 | 数值,0-不存在;1-存在 |
1 | 文件尺寸 | 数值,单位字节 |
2 | 文件时间 | 数值,格式见下 |
3 | 文件时间 | 字符串,格式:YYYY:MM:NN hh:ii |
文件时间格式:
b31-b25:年-1980
b24-b21:月
b20-b16:日
b15-b11:小时
b10-b5:分钟
示例
int a;
str filename="/a.txt";
a=getfileinfo(filename,0);
if (a==1){
//文件存在
echo("文件尺寸:");echo(getfileinfo(filename,1));echo("字节;\r\n");
echo("文件时间:");echo(getfileinfo(filename,2));echo(";\r\n");
echo("文件时间:");echo(getfileinfo(filename,3));echo(";\r\n");
}
备注
- 有关filename,建议使用全路径,比如:"0:/a.txt"、"/a.txt";不要使用"a.txt"这样的文件名,因为不确定当前所处路径,容易引起混淆