Skip to content

FileSystemManager.stat ​

JS
    Stats FileSystemManager.stat(Object object)

Get the file Stats object

Parameters

  • Object object: Input parameters; see the table below for details

Properties of object:

PropertyTypeDefaultRequiredDescription
pathstringYesFile/directory path
recursiveboolfalseNoWhether to recursively get the Stats info of each file in the directory
successfunctionNoCallback function when the call succeeds
failfunctionNoCallback function when the call fails
completefunctionNoCallback function when the call completes

Parameters of the success callback function

  • Object res: Returns the file information

Properties of res:

PropertyTypeDescription
errMsgstringError message; see the table below for details
statsStats/ObjectWhen recursive is false, res.stats is a Stats object; see the table below for details. When recursive is true and path is a directory path, res.stats is an Object whose key is the relative path with path as the root and whose value is the Stats object corresponding to that path

Valid values of errMsg:

ValueDescription
stat:okThe call succeeded

Properties of Stats

PropertyTypeDescription
modestringThe file type and access permissions, corresponding to POSIX stat.st_mode
sizenumberFile size, in bytes (B)
lastAccessedTimenumberThe time the file was last accessed or executed, as a UNIX timestamp
lastModifiedTimenumberThe time the file was last modified, as a UNIX timestamp

Parameters of the fail callback function

  • Object res: Returns the error information

Properties of res:

PropertyTypeDescription
errMsgstringError message

Valid values of errMsg:

ValueDescription
fail permission deniedNo read permission
fail no such file or directoryThe file does not exist