node.d.ts
4.03 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/// <reference types="node" />
/// <reference types="node" />
import { Volume } from './volume';
import { EventEmitter } from 'events';
import Stats from './Stats';
export declare const SEP = "/";
/**
* Node in a file system (like i-node, v-node).
*/
export declare class Node extends EventEmitter {
ino: number;
uid: number;
gid: number;
atime: Date;
mtime: Date;
ctime: Date;
buf: Buffer;
perm: number;
mode: number;
nlink: number;
symlink: string[];
constructor(ino: number, perm?: number);
getString(encoding?: string): string;
setString(str: string): void;
getBuffer(): Buffer;
setBuffer(buf: Buffer): void;
getSize(): number;
setModeProperty(property: number): void;
setIsFile(): void;
setIsDirectory(): void;
setIsSymlink(): void;
isFile(): boolean;
isDirectory(): boolean;
isSymlink(): boolean;
makeSymlink(steps: string[]): void;
write(buf: Buffer, off?: number, len?: number, pos?: number): number;
read(buf: Buffer | Uint8Array, off?: number, len?: number, pos?: number): number;
truncate(len?: number): void;
chmod(perm: number): void;
chown(uid: number, gid: number): void;
touch(): void;
canRead(uid?: number, gid?: number): boolean;
canWrite(uid?: number, gid?: number): boolean;
del(): void;
toJSON(): {
ino: number;
uid: number;
gid: number;
atime: number;
mtime: number;
ctime: number;
perm: number;
mode: number;
nlink: number;
symlink: string[];
data: string;
};
}
/**
* Represents a hard link that points to an i-node `node`.
*/
export declare class Link extends EventEmitter {
vol: Volume;
parent: Link;
children: {
[child: string]: Link | undefined;
};
private _steps;
node: Node;
ino: number;
length: number;
name: string;
get steps(): string[];
set steps(val: string[]);
constructor(vol: Volume, parent: Link, name: string);
setNode(node: Node): void;
getNode(): Node;
createChild(name: string, node?: Node): Link;
setChild(name: string, link?: Link): Link;
deleteChild(link: Link): void;
getChild(name: string): Link | undefined;
getPath(): string;
getName(): string;
/**
* Walk the tree path and return the `Link` at that location, if any.
* @param steps {string[]} Desired location.
* @param stop {number} Max steps to go into.
* @param i {number} Current step in the `steps` array.
*
* @return {Link|null}
*/
walk(steps: string[], stop?: number, i?: number): Link | null;
toJSON(): {
steps: string[];
ino: number;
children: string[];
};
syncSteps(): void;
}
/**
* Represents an open file (file descriptor) that points to a `Link` (Hard-link) and a `Node`.
*/
export declare class File {
fd: number;
/**
* Hard link that this file opened.
* @type {any}
*/
link: Link;
/**
* Reference to a `Node`.
* @type {Node}
*/
node: Node;
/**
* A cursor/offset position in a file, where data will be written on write.
* User can "seek" this position.
*/
position: number;
flags: number;
/**
* Open a Link-Node pair. `node` is provided separately as that might be a different node
* rather the one `link` points to, because it might be a symlink.
* @param link
* @param node
* @param flags
* @param fd
*/
constructor(link: Link, node: Node, flags: number, fd: number);
getString(encoding?: string): string;
setString(str: string): void;
getBuffer(): Buffer;
setBuffer(buf: Buffer): void;
getSize(): number;
truncate(len?: number): void;
seekTo(position: number): void;
stats(): Stats<number>;
write(buf: Buffer, offset?: number, length?: number, position?: number): number;
read(buf: Buffer | Uint8Array, offset?: number, length?: number, position?: number): number;
chmod(perm: number): void;
chown(uid: number, gid: number): void;
}