ProxiedFS.d.ts 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /// <reference types="node" />
  2. /// <reference types="node" />
  3. /// <reference types="node" />
  4. /// <reference types="node" />
  5. import { Stats, BigIntStats } from 'fs';
  6. import { CreateReadStreamOptions, CreateWriteStreamOptions, FakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, Dir, OpendirOptions } from './FakeFS';
  7. import { Dirent, SymlinkType, StatSyncOptions, StatOptions } from './FakeFS';
  8. import { MkdirOptions, RmdirOptions, WriteFileOptions, WatchCallback, WatchOptions, Watcher } from './FakeFS';
  9. import { FSPath, Filename, Path } from './path';
  10. export declare abstract class ProxiedFS<P extends Path, IP extends Path> extends FakeFS<P> {
  11. protected abstract readonly baseFs: FakeFS<IP>;
  12. /**
  13. * Convert a path from the user format into what should be fed into the internal FS.
  14. */
  15. protected abstract mapToBase(path: P): IP;
  16. /**
  17. * Convert a path from the format supported by the base FS into the user one.
  18. */
  19. protected abstract mapFromBase(path: IP): P;
  20. getExtractHint(hints: ExtractHintOptions): boolean;
  21. resolve(path: P): P;
  22. getRealPath(): P;
  23. openPromise(p: P, flags: string, mode?: number): Promise<number>;
  24. openSync(p: P, flags: string, mode?: number): number;
  25. opendirPromise(p: P, opts?: OpendirOptions): Promise<Dir<P>>;
  26. opendirSync(p: P, opts?: OpendirOptions): Dir<P>;
  27. readPromise(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number | null): Promise<number>;
  28. readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
  29. writePromise(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number): Promise<number>;
  30. writePromise(fd: number, buffer: string, position?: number): Promise<number>;
  31. writeSync(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number): number;
  32. writeSync(fd: number, buffer: string, position?: number): number;
  33. closePromise(fd: number): Promise<void>;
  34. closeSync(fd: number): void;
  35. createReadStream(p: P | null, opts?: CreateReadStreamOptions): import("fs").ReadStream;
  36. createWriteStream(p: P | null, opts?: CreateWriteStreamOptions): import("fs").WriteStream;
  37. realpathPromise(p: P): Promise<P>;
  38. realpathSync(p: P): P;
  39. existsPromise(p: P): Promise<boolean>;
  40. existsSync(p: P): boolean;
  41. accessSync(p: P, mode?: number): void;
  42. accessPromise(p: P, mode?: number): Promise<void>;
  43. statPromise(p: P): Promise<Stats>;
  44. statPromise(p: P, opts: (StatOptions & {
  45. bigint?: false | undefined;
  46. }) | undefined): Promise<Stats>;
  47. statPromise(p: P, opts: StatOptions & {
  48. bigint: true;
  49. }): Promise<BigIntStats>;
  50. statSync(p: P): Stats;
  51. statSync(p: P, opts?: StatSyncOptions & {
  52. bigint?: false | undefined;
  53. throwIfNoEntry: false;
  54. }): Stats | undefined;
  55. statSync(p: P, opts: StatSyncOptions & {
  56. bigint: true;
  57. throwIfNoEntry: false;
  58. }): BigIntStats | undefined;
  59. statSync(p: P, opts?: StatSyncOptions & {
  60. bigint?: false | undefined;
  61. }): Stats;
  62. statSync(p: P, opts: StatSyncOptions & {
  63. bigint: true;
  64. }): BigIntStats;
  65. statSync(p: P, opts: StatSyncOptions & {
  66. bigint: boolean;
  67. throwIfNoEntry?: false | undefined;
  68. }): Stats | BigIntStats;
  69. fstatPromise(fd: number): Promise<Stats>;
  70. fstatPromise(fd: number, opts: {
  71. bigint: true;
  72. }): Promise<BigIntStats>;
  73. fstatPromise(fd: number, opts?: {
  74. bigint: boolean;
  75. }): Promise<BigIntStats | Stats>;
  76. fstatSync(fd: number): Stats;
  77. fstatSync(fd: number, opts: {
  78. bigint: true;
  79. }): BigIntStats;
  80. fstatSync(fd: number, opts?: {
  81. bigint: boolean;
  82. }): BigIntStats | Stats;
  83. lstatPromise(p: P): Promise<Stats>;
  84. lstatPromise(p: P, opts: (StatOptions & {
  85. bigint?: false | undefined;
  86. }) | undefined): Promise<Stats>;
  87. lstatPromise(p: P, opts: StatOptions & {
  88. bigint: true;
  89. }): Promise<BigIntStats>;
  90. lstatSync(p: P): Stats;
  91. lstatSync(p: P, opts?: StatSyncOptions & {
  92. bigint?: false | undefined;
  93. throwIfNoEntry: false;
  94. }): Stats | undefined;
  95. lstatSync(p: P, opts: StatSyncOptions & {
  96. bigint: true;
  97. throwIfNoEntry: false;
  98. }): BigIntStats | undefined;
  99. lstatSync(p: P, opts?: StatSyncOptions & {
  100. bigint?: false | undefined;
  101. }): Stats;
  102. lstatSync(p: P, opts: StatSyncOptions & {
  103. bigint: true;
  104. }): BigIntStats;
  105. lstatSync(p: P, opts: StatSyncOptions & {
  106. bigint: boolean;
  107. throwIfNoEntry?: false | undefined;
  108. }): Stats | BigIntStats;
  109. fchmodPromise(fd: number, mask: number): Promise<void>;
  110. fchmodSync(fd: number, mask: number): void;
  111. chmodPromise(p: P, mask: number): Promise<void>;
  112. chmodSync(p: P, mask: number): void;
  113. fchownPromise(fd: number, uid: number, gid: number): Promise<void>;
  114. fchownSync(fd: number, uid: number, gid: number): void;
  115. chownPromise(p: P, uid: number, gid: number): Promise<void>;
  116. chownSync(p: P, uid: number, gid: number): void;
  117. renamePromise(oldP: P, newP: P): Promise<void>;
  118. renameSync(oldP: P, newP: P): void;
  119. copyFilePromise(sourceP: P, destP: P, flags?: number): Promise<void>;
  120. copyFileSync(sourceP: P, destP: P, flags?: number): void;
  121. appendFilePromise(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>;
  122. appendFileSync(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void;
  123. writeFilePromise(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>;
  124. writeFileSync(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void;
  125. unlinkPromise(p: P): Promise<void>;
  126. unlinkSync(p: P): void;
  127. utimesPromise(p: P, atime: Date | string | number, mtime: Date | string | number): Promise<void>;
  128. utimesSync(p: P, atime: Date | string | number, mtime: Date | string | number): void;
  129. mkdirPromise(p: P, opts?: MkdirOptions): Promise<string | undefined>;
  130. mkdirSync(p: P, opts?: MkdirOptions): string | undefined;
  131. rmdirPromise(p: P, opts?: RmdirOptions): Promise<void>;
  132. rmdirSync(p: P, opts?: RmdirOptions): void;
  133. linkPromise(existingP: P, newP: P): Promise<void>;
  134. linkSync(existingP: P, newP: P): void;
  135. symlinkPromise(target: P, p: P, type?: SymlinkType): Promise<void>;
  136. symlinkSync(target: P, p: P, type?: SymlinkType): void;
  137. readFilePromise(p: FSPath<P>, encoding: 'utf8'): Promise<string>;
  138. readFilePromise(p: FSPath<P>, encoding?: string): Promise<Buffer>;
  139. readFileSync(p: FSPath<P>, encoding: 'utf8'): string;
  140. readFileSync(p: FSPath<P>, encoding?: string): Buffer;
  141. readdirPromise(p: P): Promise<Array<Filename>>;
  142. readdirPromise(p: P, opts: {
  143. withFileTypes: false;
  144. } | null): Promise<Array<Filename>>;
  145. readdirPromise(p: P, opts: {
  146. withFileTypes: true;
  147. }): Promise<Array<Dirent>>;
  148. readdirPromise(p: P, opts: {
  149. withFileTypes: boolean;
  150. }): Promise<Array<Filename> | Array<Dirent>>;
  151. readdirSync(p: P): Array<Filename>;
  152. readdirSync(p: P, opts: {
  153. withFileTypes: false;
  154. } | null): Array<Filename>;
  155. readdirSync(p: P, opts: {
  156. withFileTypes: true;
  157. }): Array<Dirent>;
  158. readdirSync(p: P, opts: {
  159. withFileTypes: boolean;
  160. }): Array<Filename> | Array<Dirent>;
  161. readlinkPromise(p: P): Promise<P>;
  162. readlinkSync(p: P): P;
  163. truncatePromise(p: P, len?: number): Promise<void>;
  164. truncateSync(p: P, len?: number): void;
  165. ftruncatePromise(fd: number, len?: number): Promise<void>;
  166. ftruncateSync(fd: number, len?: number): void;
  167. watch(p: P, cb?: WatchCallback): Watcher;
  168. watch(p: P, opts: WatchOptions, cb?: WatchCallback): Watcher;
  169. watchFile(p: P, cb: WatchFileCallback): StatWatcher;
  170. watchFile(p: P, opts: WatchFileOptions, cb: WatchFileCallback): StatWatcher;
  171. unwatchFile(p: P, cb?: WatchFileCallback): void;
  172. private fsMapToBase;
  173. }