Wednesday 17 October 2018

fs.statSync(path[, options]): get the statistics or information about a file

fs.statSync(path[, options])
This method returns the statistics about a file like whether it is a directory, file or socket, lastmodified date etc.,

Below table summarizes the arguments of statSync method.
Argument
Type
Description
path
path or Buffer or URL
Specifies the path of the file.
options
Object
Below table summarizes the options of statSync function.
Option
Type
Description
bigint
boolean
It specifies, whether the numeric values in the returned fs.Stats object should be bigint.

Default value is false.

Find the below working application.

HelloWorld.js
var fs = require('fs');

var filePath = 'input.txt';

var stats = fs.statSync(filePath);

console.log(stats);


Sample output

Stats {
  dev: 271863663,
  mode: 33206,
  nlink: 1,
  uid: 0,
  gid: 0,
  rdev: 0,
  blksize: undefined,
  ino: 18014398510246784,
  size: 204,
  blocks: undefined,
  atimeMs: 1535473478571.7754,
  mtimeMs: 1535477562609.0286,
  ctimeMs: 1535477562609.0286,
  birthtimeMs: 1535473478571.7754,
  atime: 2018-08-28T16:24:38.572Z,
  mtime: 2018-08-28T17:32:42.609Z,
  ctime: 2018-08-28T17:32:42.609Z,
  birthtime: 2018-08-28T16:24:38.572Z }




Previous                                                 Next                                                 Home

No comments:

Post a Comment