node.js中的fs.lstat方法使用说明_node.js

WBOY
Release: 2016-05-16 16:26:33
Original
1633 people have browsed it

方法说明:

获取文件信息(不解析符号链接)。

语法:

复制代码代码如下:

fs.lstat(path, [callback(err, stats)])

由于该方法属于fs模块,使用前需要引入fs模块(var fs= require(“fs”) )

接收参数:

path 文件路径

callback 回调,传递两个参数,异常参数err, 文件信息数组 stats

stats包含以下信息:(以下信息为案例中读取的文件信息,非默认值)

复制代码代码如下:

{

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 ,

mtime : Tue Jun 13 2014 09:48:31 GMT +0800 ,

ctime : Tue Jun 10 2014 13:57:13 GMT +0800

}

例子:

复制代码代码如下:

var fs = require('fs');
fs.lstat('content.txt', function(err, stats){
if(err){
throw err;
}else{
console.log(stats);
}
})

源码:

复制代码代码如下:

fs.lstat = function(path, callback) {
callback = makeCallback(callback);
if (!nullCheck(path, callback)) return;
binding.lstat(pathModule._makeLong(path), callback);
};
Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!