UNPKG

5.55 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 return function (d, b) {
7 extendStatics(d, b);
8 function __() { this.constructor = d; }
9 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10 };
11})();
12Object.defineProperty(exports, "__esModule", { value: true });
13var dev = Math.floor(Math.random() * 10000);
14var VirtualStats = (function () {
15 function VirtualStats(_path) {
16 this._path = _path;
17 this._ctime = new Date();
18 this._mtime = new Date();
19 this._atime = new Date();
20 this._btime = new Date();
21 this._dev = dev;
22 this._ino = Math.floor(Math.random() * 100000);
23 this._mode = parseInt('777', 8); // RWX for everyone.
24 this._uid = process.env['UID'] ? parseInt(process.env['UID'], 0) : 0;
25 this._gid = process.env['GID'] ? parseInt(process.env['GID'], 0) : 0;
26 }
27 VirtualStats.prototype.isFile = function () { return false; };
28 VirtualStats.prototype.isDirectory = function () { return false; };
29 VirtualStats.prototype.isBlockDevice = function () { return false; };
30 VirtualStats.prototype.isCharacterDevice = function () { return false; };
31 VirtualStats.prototype.isSymbolicLink = function () { return false; };
32 VirtualStats.prototype.isFIFO = function () { return false; };
33 VirtualStats.prototype.isSocket = function () { return false; };
34 Object.defineProperty(VirtualStats.prototype, "dev", {
35 get: function () { return this._dev; },
36 enumerable: true,
37 configurable: true
38 });
39 Object.defineProperty(VirtualStats.prototype, "ino", {
40 get: function () { return this._ino; },
41 enumerable: true,
42 configurable: true
43 });
44 Object.defineProperty(VirtualStats.prototype, "mode", {
45 get: function () { return this._mode; },
46 enumerable: true,
47 configurable: true
48 });
49 Object.defineProperty(VirtualStats.prototype, "nlink", {
50 get: function () { return 1; } // Default to 1 hard link.
51 ,
52 enumerable: true,
53 configurable: true
54 });
55 Object.defineProperty(VirtualStats.prototype, "uid", {
56 get: function () { return this._uid; },
57 enumerable: true,
58 configurable: true
59 });
60 Object.defineProperty(VirtualStats.prototype, "gid", {
61 get: function () { return this._gid; },
62 enumerable: true,
63 configurable: true
64 });
65 Object.defineProperty(VirtualStats.prototype, "rdev", {
66 get: function () { return 0; },
67 enumerable: true,
68 configurable: true
69 });
70 Object.defineProperty(VirtualStats.prototype, "size", {
71 get: function () { return 0; },
72 enumerable: true,
73 configurable: true
74 });
75 Object.defineProperty(VirtualStats.prototype, "blksize", {
76 get: function () { return 512; },
77 enumerable: true,
78 configurable: true
79 });
80 Object.defineProperty(VirtualStats.prototype, "blocks", {
81 get: function () { return Math.ceil(this.size / this.blksize); },
82 enumerable: true,
83 configurable: true
84 });
85 Object.defineProperty(VirtualStats.prototype, "atime", {
86 get: function () { return this._atime; },
87 enumerable: true,
88 configurable: true
89 });
90 Object.defineProperty(VirtualStats.prototype, "mtime", {
91 get: function () { return this._mtime; },
92 enumerable: true,
93 configurable: true
94 });
95 Object.defineProperty(VirtualStats.prototype, "ctime", {
96 get: function () { return this._ctime; },
97 enumerable: true,
98 configurable: true
99 });
100 Object.defineProperty(VirtualStats.prototype, "birthtime", {
101 get: function () { return this._btime; },
102 enumerable: true,
103 configurable: true
104 });
105 return VirtualStats;
106}());
107exports.VirtualStats = VirtualStats;
108var VirtualDirStats = (function (_super) {
109 __extends(VirtualDirStats, _super);
110 function VirtualDirStats(_fileName) {
111 return _super.call(this, _fileName) || this;
112 }
113 VirtualDirStats.prototype.isDirectory = function () { return true; };
114 Object.defineProperty(VirtualDirStats.prototype, "size", {
115 get: function () { return 1024; },
116 enumerable: true,
117 configurable: true
118 });
119 return VirtualDirStats;
120}(VirtualStats));
121exports.VirtualDirStats = VirtualDirStats;
122var VirtualFileStats = (function (_super) {
123 __extends(VirtualFileStats, _super);
124 function VirtualFileStats(_fileName, _content) {
125 var _this = _super.call(this, _fileName) || this;
126 _this._content = _content;
127 return _this;
128 }
129 Object.defineProperty(VirtualFileStats.prototype, "content", {
130 get: function () { return this._content; },
131 set: function (v) {
132 this._content = v;
133 this._mtime = new Date();
134 },
135 enumerable: true,
136 configurable: true
137 });
138 VirtualFileStats.prototype.isFile = function () { return true; };
139 Object.defineProperty(VirtualFileStats.prototype, "size", {
140 get: function () { return this._content.length; },
141 enumerable: true,
142 configurable: true
143 });
144 return VirtualFileStats;
145}(VirtualStats));
146exports.VirtualFileStats = VirtualFileStats;