Description of the fs. fstat method in node. js, node. jsfs. fstat

Source: Internet
Author: User
Tags lstat

Description of the fs. fstat method in node. js, node. jsfs. fstat

Method description:

Obtain the file information based on the file descriptor.

Syntax:

Copy codeThe Code is as follows:
Fs. fstat (fd, [callback (err, stats)])

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

Receiving parameters:

Fd file descriptor

Callback. Two parameters are passed, namely the error 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)

Copy codeThe Code is as follows:
{
 
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 <China Standard Time>,
 
Mtime: Tue Jun 13 2014 09:48:31 GMT + 0800 <China Standard Time>,
 
Ctime: Tue Jun 10 2014 13:57:13 GMT + 0800 <China Standard Time>
 
}

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 ');
Fs. fstat (fd, function (err, stats ){
If (err ){
Throw err;
}
Console. log (stats );
Fs. close (fd, function (){
Console. log ('file close ');
})
})
})

Source code:

Copy codeThe Code is as follows:
Fs. lstat = function (path, callback ){
Callback = makeCallback (callback );
If (! NullCheck (path, callback) return;
Binding. lstat (pathModule. _ makeLong (path), callback );
};

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.