1 | /// <reference types="node" />
|
---|
2 | import { Volume } from './volume';
|
---|
3 | import { EventEmitter } from 'events';
|
---|
4 | import Stats from './Stats';
|
---|
5 | export declare const SEP = "/";
|
---|
6 | /**
|
---|
7 | * Node in a file system (like i-node, v-node).
|
---|
8 | */
|
---|
9 | export declare class Node extends EventEmitter {
|
---|
10 | ino: number;
|
---|
11 | uid: number;
|
---|
12 | gid: number;
|
---|
13 | atime: Date;
|
---|
14 | mtime: Date;
|
---|
15 | ctime: Date;
|
---|
16 | buf: Buffer;
|
---|
17 | perm: number;
|
---|
18 | mode: number;
|
---|
19 | nlink: number;
|
---|
20 | symlink: string[];
|
---|
21 | constructor(ino: number, perm?: number);
|
---|
22 | getString(encoding?: string): string;
|
---|
23 | setString(str: string): void;
|
---|
24 | getBuffer(): Buffer;
|
---|
25 | setBuffer(buf: Buffer): void;
|
---|
26 | getSize(): number;
|
---|
27 | setModeProperty(property: number): void;
|
---|
28 | setIsFile(): void;
|
---|
29 | setIsDirectory(): void;
|
---|
30 | setIsSymlink(): void;
|
---|
31 | isFile(): boolean;
|
---|
32 | isDirectory(): boolean;
|
---|
33 | isSymlink(): boolean;
|
---|
34 | makeSymlink(steps: string[]): void;
|
---|
35 | write(buf: Buffer, off?: number, len?: number, pos?: number): number;
|
---|
36 | read(buf: Buffer | Uint8Array, off?: number, len?: number, pos?: number): number;
|
---|
37 | truncate(len?: number): void;
|
---|
38 | chmod(perm: number): void;
|
---|
39 | chown(uid: number, gid: number): void;
|
---|
40 | touch(): void;
|
---|
41 | canRead(uid?: number, gid?: number): boolean;
|
---|
42 | canWrite(uid?: number, gid?: number): boolean;
|
---|
43 | del(): void;
|
---|
44 | toJSON(): {
|
---|
45 | ino: number;
|
---|
46 | uid: number;
|
---|
47 | gid: number;
|
---|
48 | atime: number;
|
---|
49 | mtime: number;
|
---|
50 | ctime: number;
|
---|
51 | perm: number;
|
---|
52 | mode: number;
|
---|
53 | nlink: number;
|
---|
54 | symlink: string[];
|
---|
55 | data: string;
|
---|
56 | };
|
---|
57 | }
|
---|
58 | /**
|
---|
59 | * Represents a hard link that points to an i-node `node`.
|
---|
60 | */
|
---|
61 | export declare class Link extends EventEmitter {
|
---|
62 | vol: Volume;
|
---|
63 | parent: Link;
|
---|
64 | children: {
|
---|
65 | [child: string]: Link | undefined;
|
---|
66 | };
|
---|
67 | steps: string[];
|
---|
68 | node: Node;
|
---|
69 | ino: number;
|
---|
70 | length: number;
|
---|
71 | constructor(vol: Volume, parent: Link, name: string);
|
---|
72 | setNode(node: Node): void;
|
---|
73 | getNode(): Node;
|
---|
74 | createChild(name: string, node?: Node): Link;
|
---|
75 | setChild(name: string, link?: Link): Link;
|
---|
76 | deleteChild(link: Link): void;
|
---|
77 | getChild(name: string): Link | undefined;
|
---|
78 | getPath(): string;
|
---|
79 | getName(): string;
|
---|
80 | /**
|
---|
81 | * Walk the tree path and return the `Link` at that location, if any.
|
---|
82 | * @param steps {string[]} Desired location.
|
---|
83 | * @param stop {number} Max steps to go into.
|
---|
84 | * @param i {number} Current step in the `steps` array.
|
---|
85 | *
|
---|
86 | * @return {Link|null}
|
---|
87 | */
|
---|
88 | walk(steps: string[], stop?: number, i?: number): Link | null;
|
---|
89 | toJSON(): {
|
---|
90 | steps: string[];
|
---|
91 | ino: number;
|
---|
92 | children: string[];
|
---|
93 | };
|
---|
94 | }
|
---|
95 | /**
|
---|
96 | * Represents an open file (file descriptor) that points to a `Link` (Hard-link) and a `Node`.
|
---|
97 | */
|
---|
98 | export declare class File {
|
---|
99 | fd: number;
|
---|
100 | /**
|
---|
101 | * Hard link that this file opened.
|
---|
102 | * @type {any}
|
---|
103 | */
|
---|
104 | link: Link;
|
---|
105 | /**
|
---|
106 | * Reference to a `Node`.
|
---|
107 | * @type {Node}
|
---|
108 | */
|
---|
109 | node: Node;
|
---|
110 | /**
|
---|
111 | * A cursor/offset position in a file, where data will be written on write.
|
---|
112 | * User can "seek" this position.
|
---|
113 | */
|
---|
114 | position: number;
|
---|
115 | flags: number;
|
---|
116 | /**
|
---|
117 | * Open a Link-Node pair. `node` is provided separately as that might be a different node
|
---|
118 | * rather the one `link` points to, because it might be a symlink.
|
---|
119 | * @param link
|
---|
120 | * @param node
|
---|
121 | * @param flags
|
---|
122 | * @param fd
|
---|
123 | */
|
---|
124 | constructor(link: Link, node: Node, flags: number, fd: number);
|
---|
125 | getString(encoding?: string): string;
|
---|
126 | setString(str: string): void;
|
---|
127 | getBuffer(): Buffer;
|
---|
128 | setBuffer(buf: Buffer): void;
|
---|
129 | getSize(): number;
|
---|
130 | truncate(len?: number): void;
|
---|
131 | seekTo(position: number): void;
|
---|
132 | stats(): Stats<number>;
|
---|
133 | write(buf: Buffer, offset?: number, length?: number, position?: number): number;
|
---|
134 | read(buf: Buffer | Uint8Array, offset?: number, length?: number, position?: number): number;
|
---|
135 | chmod(perm: number): void;
|
---|
136 | chown(uid: number, gid: number): void;
|
---|
137 | }
|
---|