UNPKG

@loom-io/node-filesystem-adapter

Version:

A file system wrapper for Node.js and Bun

32 lines (31 loc) 1.36 kB
import { FileHandler } from './file-handler.js'; import * as fs from 'node:fs/promises'; import type { SourceAdapter, rmdirOptions, ObjectDirentInterface } from '@loom-io/core'; import { PathLike } from 'node:fs'; export declare class Adapter implements SourceAdapter { protected rootdir: string; constructor(rootdir?: PathLike); get raw(): typeof fs; protected getFullPath(path: string): string; protected getRelativePath(path: string): string; protected exists(path: string, ref: number): Promise<boolean>; fileExists(path: string): Promise<boolean>; dirExists(path: string): Promise<boolean>; mkdir(path: string): Promise<void>; readdir(path: PathLike): Promise<ObjectDirentInterface[]>; rmdir(path: string, options?: rmdirOptions): Promise<void>; stat(path: string): Promise<{ size: number; atime: Date; mtime: Date; ctime: Date; birthtime: Date; }>; readFile(path: string): Promise<Buffer>; readFile(path: string, encoding: BufferEncoding): Promise<string>; writeFile(path: string, data: Buffer | string): Promise<void>; deleteFile(path: PathLike): Promise<void>; openFile(path: string, mode?: 'r' | 'w'): Promise<FileHandler>; isCopyable(adapter: SourceAdapter): Promise<boolean>; copyFile(from: string, to: string): Promise<void>; }