| 247 | } |
| 248 | |
| 249 | export class NullFile implements IFile { |
| 250 | fd: number; |
| 251 | pos: number; |
| 252 | |
| 253 | refCount: number; |
| 254 | |
| 255 | constructor() { |
| 256 | this.refCount = 1; |
| 257 | this.pos = 0; |
| 258 | } |
| 259 | |
| 260 | read(buf: Buffer, pos: number, cb: (err: any, len?: number) => void): void { |
| 261 | cb(null, 0); |
| 262 | } |
| 263 | |
| 264 | write(buf: Buffer, pos: number, cb: (err: any, len?: number) => void): void { |
| 265 | cb(null, buf.length); |
| 266 | } |
| 267 | |
| 268 | stat(cb: (err: any, stats: any) => void): void { |
| 269 | cb(null, new Stats(FileType.FILE, 0, 0x309)); |
| 270 | } |
| 271 | |
| 272 | readdir(cb: (err: any, files: string[]) => void): void { |
| 273 | setTimeout(cb, 0, 'cant readdir on /dev/null'); |
| 274 | } |
| 275 | |
| 276 | llseek(offhi: number, offlo: number, whence: number, cb: (err: number, off: number) => void): void { |
| 277 | this.pos = 0; |
| 278 | cb(0, this.pos); |
| 279 | } |
| 280 | |
| 281 | ref(): void { |
| 282 | this.refCount++; |
| 283 | } |
| 284 | |
| 285 | unref(): void { |
| 286 | this.refCount--; |
| 287 | // FIXME: verify this is what we want. |
| 288 | if (!this.refCount) { |
| 289 | this.fd = undefined; |
| 290 | } |
| 291 | } |
| 292 | } |
nothing calls this directly
no outgoing calls
no test coverage detected