[6a3a178] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | exports.Dirent = void 0;
|
---|
| 4 | var constants_1 = require("./constants");
|
---|
| 5 | var encoding_1 = require("./encoding");
|
---|
| 6 | var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFBLK = constants_1.constants.S_IFBLK, S_IFCHR = constants_1.constants.S_IFCHR, S_IFLNK = constants_1.constants.S_IFLNK, S_IFIFO = constants_1.constants.S_IFIFO, S_IFSOCK = constants_1.constants.S_IFSOCK;
|
---|
| 7 | /**
|
---|
| 8 | * A directory entry, like `fs.Dirent`.
|
---|
| 9 | */
|
---|
| 10 | var Dirent = /** @class */ (function () {
|
---|
| 11 | function Dirent() {
|
---|
| 12 | this.name = '';
|
---|
| 13 | this.mode = 0;
|
---|
| 14 | }
|
---|
| 15 | Dirent.build = function (link, encoding) {
|
---|
| 16 | var dirent = new Dirent();
|
---|
| 17 | var mode = link.getNode().mode;
|
---|
| 18 | dirent.name = (0, encoding_1.strToEncoding)(link.getName(), encoding);
|
---|
| 19 | dirent.mode = mode;
|
---|
| 20 | return dirent;
|
---|
| 21 | };
|
---|
| 22 | Dirent.prototype._checkModeProperty = function (property) {
|
---|
| 23 | return (this.mode & S_IFMT) === property;
|
---|
| 24 | };
|
---|
| 25 | Dirent.prototype.isDirectory = function () {
|
---|
| 26 | return this._checkModeProperty(S_IFDIR);
|
---|
| 27 | };
|
---|
| 28 | Dirent.prototype.isFile = function () {
|
---|
| 29 | return this._checkModeProperty(S_IFREG);
|
---|
| 30 | };
|
---|
| 31 | Dirent.prototype.isBlockDevice = function () {
|
---|
| 32 | return this._checkModeProperty(S_IFBLK);
|
---|
| 33 | };
|
---|
| 34 | Dirent.prototype.isCharacterDevice = function () {
|
---|
| 35 | return this._checkModeProperty(S_IFCHR);
|
---|
| 36 | };
|
---|
| 37 | Dirent.prototype.isSymbolicLink = function () {
|
---|
| 38 | return this._checkModeProperty(S_IFLNK);
|
---|
| 39 | };
|
---|
| 40 | Dirent.prototype.isFIFO = function () {
|
---|
| 41 | return this._checkModeProperty(S_IFIFO);
|
---|
| 42 | };
|
---|
| 43 | Dirent.prototype.isSocket = function () {
|
---|
| 44 | return this._checkModeProperty(S_IFSOCK);
|
---|
| 45 | };
|
---|
| 46 | return Dirent;
|
---|
| 47 | }());
|
---|
| 48 | exports.Dirent = Dirent;
|
---|
| 49 | exports.default = Dirent;
|
---|