Method description:
Get file information based on file descriptor.
Grammar:
fs.fstat(fd, [callback(err, stats)])
Since this method belongs to the fs module, the fs module needs to be introduced before use (var fs= require(“fs”) )
Receive parameters:
fd File descriptor
callback callback, passing 2 parameters, the exception parameter err and the file information parameter stats
stats contains the following information: (The following information is the file information read in the case, not the default value)
{
dev : 0 ,
mode: 33206,
nlink : 1 ,
uid : 0 ,
gid : 0 ,
rdev : 0 ,
ino : 0 ,
size: 378 (bytes) ,
atime : Tue Jun 10 2014 13:57:13 GMT 0800 ,
mtime : Tue Jun 13 2014 09:48:31 GMT 0800 ,
ctime : Tue Jun 10 2014 13:57:13 GMT 0800
}
Example:
var fs = require('fs');
fs.open('content.txt', 'a', function(err,fd){
if(err){
throw err;
}
console.log('file open');
fs.fstat(fd, function(err, stats){
if(err){
throw err;
}
console.log(stats);
fs.close(fd, function(){
console.log('file close');
})
})
})
Source code:
fs.lstat = function(path, callback) {
callback = makeCallback(callback);
if (!nullCheck(path, callback)) return;
binding.lstat(pathModule._makeLong(path), callback);
};