跳到主要内容
CNode

readdir 如何按时间顺序读取文件(夹)列表?

社区
Ccloudcome发布于 13 年前最后回复 13 年前
4106320

#如题

查看回复

回复 (4)

Y
yorkie#313 年前
引用 yorkie使用http://nodejs.org/api/fs.html fs class fs stats,然后自己排序

@cloudcome 如果你是*nix上也可以:

var exec = require('child_process').exec;
exec('ls -t '+yourDirPath, function(err, stdout, stderr) {
  // TODO
})
C
cloudcome#213 年前
引用 yorkie使用http://nodejs.org/api/fs.html fs class fs stats,然后自己排序

那这样是不是要读取1次列表+N次stats属性了?

参与回复

登录后即可参与回复。登录