@zenfs/core
Version:
A filesystem, anywhere
37 lines (36 loc) • 894 B
JavaScript
// SPDX-License-Identifier: LGPL-3.0-or-later
/**
* @see `DT_*` in `dirent.h`
*/
export var DirType;
(function (DirType) {
DirType[DirType["UNKNOWN"] = 0] = "UNKNOWN";
DirType[DirType["FIFO"] = 1] = "FIFO";
DirType[DirType["CHR"] = 2] = "CHR";
DirType[DirType["DIR"] = 4] = "DIR";
DirType[DirType["BLK"] = 6] = "BLK";
DirType[DirType["REG"] = 8] = "REG";
DirType[DirType["LNK"] = 10] = "LNK";
DirType[DirType["SOCK"] = 12] = "SOCK";
DirType[DirType["WHT"] = 14] = "WHT";
})(DirType || (DirType = {}));
/**
* Converts a file mode to a directory type.
* @see `IFTODT` in `dirent.h`
*/
export function ifToDt(mode) {
return ((mode & 0o170000) >> 12);
}
/**
* Converts a directory type to a file mode.
* @see `DTTOIF` in `dirent.h`
*/
export function dtToIf(dt) {
return dt << 12;
}
export class Dirent {
ino;
type;
path;
name;
}