Home  >  Article  >  Web Front-end  >  Instructions for using the fs.fstatSync method in node.js

Instructions for using the fs.fstatSync method in node.js

ringa_lee
ringa_leeOriginal
2018-05-11 13:54:332212browse

Method description:

Synchronized version of fstat().

The method returns a stat array object, including the following information: (The following information is the file information read in the case, non-default value)

Copy code The code is as follows:

{
 
 dev : 0 ,
 
 mode : 33206 ,
 
 nlink : 1 ,
 
 uid : 0 ,
 
 gid : 0 ,
 
 rdev : 0 ,
 
 ino : 0 ,
 
 size : 378(字节) ,
 
 atime : Tue Jun 10 2014 13:57:13 GMT +0800

Syntax:

Copy the code The code is as follows:

fs.fstatSync(fd)

Since this method belongs to the fs module, you need to introduce the fs module before use (var fs= require("fs"))

Receive parameters:

fd File descriptor

Example:

Copy codeThe code is as follows:

var fs = require('fs');
fs.open('content.txt', 'a', function(err,fd){
 if(err){
  throw err;
 }
 console.log('file open');
 
 var statInfo = fs.fstatSync(fd);
 console.log(statInfo);
 
 fs.close(fd , function(){
  console.log('file close');
 })
})

Source code:

Copy code The code is as follows:

fs.fstatSync = function(fd) {
  return binding.fstat(fd);
};


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn