FileHandle.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930
  1. /// <reference types="node" />
  2. import type * as opts from './types/options';
  3. import type { IFileHandle, IStats, TData, TDataOut, TMode, TTime } from './types/misc';
  4. import type { FsCallbackApi } from './types';
  5. export declare class FileHandle implements IFileHandle {
  6. private fs;
  7. fd: number;
  8. constructor(fs: FsCallbackApi, fd: number);
  9. appendFile(data: TData, options?: opts.IAppendFileOptions | string): Promise<void>;
  10. chmod(mode: TMode): Promise<void>;
  11. chown(uid: number, gid: number): Promise<void>;
  12. close(): Promise<void>;
  13. datasync(): Promise<void>;
  14. read(buffer: Buffer | Uint8Array, offset: number, length: number, position: number): Promise<TFileHandleReadResult>;
  15. readFile(options?: opts.IReadFileOptions | string): Promise<TDataOut>;
  16. stat(options?: opts.IFStatOptions): Promise<IStats>;
  17. sync(): Promise<void>;
  18. truncate(len?: number): Promise<void>;
  19. utimes(atime: TTime, mtime: TTime): Promise<void>;
  20. write(buffer: Buffer | Uint8Array, offset?: number, length?: number, position?: number): Promise<TFileHandleWriteResult>;
  21. writeFile(data: TData, options?: opts.IWriteFileOptions): Promise<void>;
  22. }
  23. export interface TFileHandleReadResult {
  24. bytesRead: number;
  25. buffer: Buffer | Uint8Array;
  26. }
  27. export interface TFileHandleWriteResult {
  28. bytesWritten: number;
  29. buffer: Buffer | Uint8Array;
  30. }