-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathstat.js
51 lines (42 loc) · 1017 Bytes
/
stat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var toDate = function(date) {
if (!date) return new Date();
if (typeof date === 'string') return new Date(date);
return date;
};
var Stat = function(opts) {
this.uid = opts.uid || 0;
this.gid = opts.gid || 0;
this.mode = opts.mode || 0;
this.size = opts.size || 0;
this.mtime = toDate(opts.mtime);
this.atime = toDate(opts.atime);
this.ctime = toDate(opts.ctime);
this.type = opts.type;
this.target = opts.target;
this.link = opts.link;
this.blob = opts.blob;
};
Stat.prototype.isDirectory = function() {
return this.type === 'directory';
};
Stat.prototype.isFile = function() {
return this.type === 'file';
};
Stat.prototype.isBlockDevice = function() {
return false;
};
Stat.prototype.isCharacterDevice = function() {
return false;
};
Stat.prototype.isSymbolicLink = function() {
return this.type === 'symlink';
};
Stat.prototype.isFIFO = function() {
return false;
};
Stat.prototype.isSocket = function() {
return false;
};
module.exports = function(opts) {
return new Stat(opts);
};