FileSystemManager.statSync

解释:获取文件 Stats 对象的同步接口。

Web 态说明:受浏览器限制,Web 态不支持文件系统相关功能,调用该方法会抛出一个标准的 Error 对象。

方法参数

String path
path 参数说明:临时存储文件路径。
返回值:Stats stats
stats 返回值说明

参数名参数类型说明

mode

String

文件的类型和存取的权限,对应 POSIX stat.st_mode

size

Number

文件大小(单位:B),对应 POSIX stat.st_size

lastAccessedTime

Number

文件最近一次被存取或被执行的时间,UNIX 时间戳,对应 POSIX stat.st_atime

lastModifiedTime

Number

文件最后一次被修改的时间,UNIX 时间戳,对应 POSIX stat.st_mtime

isDirectory

Function

判断当前文件是否一个目录,返回 boolean 值

isFile

Function

判断当前文件是否一个普通文件,返回 boolean 值

若接口调用失败,会抛出一个标准的Error对象

示例

跳转编辑工具

在开发者工具中打开

在 WEB IDE 中打开

扫码体验

代码示例

百度智能小程序

请使用百度APP扫码

图片示例

FileSystemManager.statSync - 图2

代码示例

  • SWAN
  • JS
  1. <view class="wrap">
  2. <button type="primary" bindtap="stat">获取文件 Stats 对象</button>
  3. </view>