FileSystem
Constructor
FileDescriptor
Added in v1.0.0
Source
Signature
declare const FileDescriptor: Constructor<Descriptor>;Signature
declare const make: (
impl: Omit<FileSystem, "exists" | "readFileString" | "stream" | "sink" | "writeFileString">,
) => FileSystem;Signature
declare const makeNoop: (fileSystem: Partial<FileSystem>) => FileSystem;WatchEventCreate
Added in v1.0.0
Source
Signature
declare const WatchEventCreate: Data.Case.Constructor<WatchEvent.Create, "_tag">;WatchEventRemove
Added in v1.0.0
Source
Signature
declare const WatchEventRemove: Data.Case.Constructor<WatchEvent.Remove, "_tag">;WatchEventUpdate
Added in v1.0.0
Source
Signature
declare const WatchEventUpdate: Data.Case.Constructor<WatchEvent.Update, "_tag">;File Watcher
WatchBackend
Added in v1.0.0
Source
Signature
declare class WatchBackend extends any {
constructor();
}Guard
Layers
Model
Signature
interface File {
readonly [FileTypeId]: typeof FileTypeId;
readonly fd: Descriptor;
readonly read: (buffer: Uint8Array) => Effect<Size, PlatformError>;
readonly readAlloc: (
size: SizeInput,
) => Effect<Option<Uint8Array<ArrayBufferLike>>, PlatformError>;
readonly seek: (offset: SizeInput, from: SeekMode) => Effect<void>;
readonly stat: Effect<Info, PlatformError>;
readonly sync: Effect<void, PlatformError>;
readonly truncate: (length?: SizeInput) => Effect<void, PlatformError>;
readonly write: (buffer: Uint8Array) => Effect<Size, PlatformError>;
readonly writeAll: (buffer: Uint8Array) => Effect<void, PlatformError>;
}FileSystem interface
Added in v1.0.0
Source
Signature
interface FileSystem {
readonly access: (path: string, options?: AccessFileOptions) => Effect<void, PlatformError>;
readonly chmod: (path: string, mode: number) => Effect<void, PlatformError>;
readonly chown: (path: string, uid: number, gid: number) => Effect<void, PlatformError>;
readonly copy: (
fromPath: string,
toPath: string,
options?: CopyOptions,
) => Effect<void, PlatformError>;
readonly copyFile: (fromPath: string, toPath: string) => Effect<void, PlatformError>;
readonly exists: (path: string) => Effect<boolean, PlatformError>;
readonly link: (fromPath: string, toPath: string) => Effect<void, PlatformError>;
readonly makeDirectory: (
path: string,
options?: MakeDirectoryOptions,
) => Effect<void, PlatformError>;
readonly makeTempDirectory: (options?: MakeTempDirectoryOptions) => Effect<string, PlatformError>;
readonly makeTempDirectoryScoped: (
options?: MakeTempDirectoryOptions,
) => Effect<string, PlatformError, Scope>;
readonly makeTempFile: (options?: MakeTempFileOptions) => Effect<string, PlatformError>;
readonly makeTempFileScoped: (
options?: MakeTempFileOptions,
) => Effect<string, PlatformError, Scope>;
readonly open: (path: string, options?: OpenFileOptions) => Effect<File, PlatformError, Scope>;
readonly readDirectory: (
path: string,
options?: ReadDirectoryOptions,
) => Effect<Array<string>, PlatformError>;
readonly readFile: (path: string) => Effect<Uint8Array<ArrayBufferLike>, PlatformError>;
readonly readFileString: (path: string, encoding?: string) => Effect<string, PlatformError>;
readonly readLink: (path: string) => Effect<string, PlatformError>;
readonly realPath: (path: string) => Effect<string, PlatformError>;
readonly remove: (path: string, options?: RemoveOptions) => Effect<void, PlatformError>;
readonly rename: (oldPath: string, newPath: string) => Effect<void, PlatformError>;
readonly sink: (
path: string,
options?: SinkOptions,
) => Sink<void, Uint8Array<ArrayBufferLike>, never, PlatformError>;
readonly stat: (path: string) => Effect<Info, PlatformError>;
readonly stream: (
path: string,
options?: StreamOptions,
) => Stream<Uint8Array<ArrayBufferLike>, PlatformError>;
readonly symlink: (fromPath: string, toPath: string) => Effect<void, PlatformError>;
readonly truncate: (path: string, length?: SizeInput) => Effect<void, PlatformError>;
readonly utimes: (
path: string,
atime: number | Date,
mtime: number | Date,
) => Effect<void, PlatformError>;
readonly watch: (path: string, options?: WatchOptions) => Stream<WatchEvent, PlatformError>;
readonly writeFile: (
path: string,
data: Uint8Array,
options?: WriteFileOptions,
) => Effect<void, PlatformError>;
readonly writeFileString: (
path: string,
data: string,
options?: WriteFileStringOptions,
) => Effect<void, PlatformError>;
}Signature
type OpenFlag = "r" | "r+" | "w" | "wx" | "w+" | "wx+" | "a" | "ax" | "a+" | "ax+";Signature
type SeekMode = "start" | "current";WatchEvent
Added in v1.0.0
Source
WatchEvent type
Added in v1.0.0
Source
Signature
type WatchEvent = WatchEvent.Create | WatchEvent.Update | WatchEvent.Remove;Options
AccessFileOptions interface
Added in v1.0.0
Source
Signature
interface AccessFileOptions {
readonly ok?: boolean;
readonly readable?: boolean;
readonly writable?: boolean;
}CopyOptions interface
Added in v1.0.0
Source
Signature
interface CopyOptions {
readonly overwrite?: boolean;
readonly preserveTimestamps?: boolean;
}MakeDirectoryOptions interface
Added in v1.0.0
Source
Signature
interface MakeDirectoryOptions {
readonly mode?: number;
readonly recursive?: boolean;
}MakeTempDirectoryOptions interface
Added in v1.0.0
Source
Signature
interface MakeTempDirectoryOptions {
readonly directory?: string;
readonly prefix?: string;
}MakeTempFileOptions interface
Added in v1.0.0
Source
Signature
interface MakeTempFileOptions {
readonly directory?: string;
readonly prefix?: string;
readonly suffix?: string;
}OpenFileOptions interface
Added in v1.0.0
Source
Signature
interface OpenFileOptions {
readonly flag?: OpenFlag;
readonly mode?: number;
}ReadDirectoryOptions interface
Added in v1.0.0
Source
Signature
interface ReadDirectoryOptions {
readonly recursive?: boolean;
}RemoveOptions interface
Added in v1.0.0
Source
Signature
interface RemoveOptions {
readonly force?: boolean;
readonly recursive?: boolean;
}SinkOptions interface
Added in v1.0.0
Source
Signature
interface SinkOptions extends OpenFileOptions {}StreamOptions interface
Added in v1.0.0
Source
Signature
interface StreamOptions {
readonly bufferSize?: number;
readonly bytesToRead?: SizeInput;
readonly chunkSize?: SizeInput;
readonly offset?: SizeInput;
}WatchOptions interface
Added in v1.0.0
Source
Signature
interface WatchOptions {
readonly recursive?: boolean;
}WriteFileOptions interface
Added in v1.0.0
Source
Signature
interface WriteFileOptions {
readonly flag?: OpenFlag;
readonly mode?: number;
}WriteFileStringOptions interface
Added in v1.0.0
Source
Signature
interface WriteFileStringOptions {
readonly flag?: OpenFlag;
readonly mode?: number;
}Other
Sizes
Signature
declare const GiB: (n: number) => Size;Signature
declare const KiB: (n: number) => Size;Signature
declare const MiB: (n: number) => Size;Signature
declare const PiB: (n: number) => Size;Signature
declare const Size: (bytes: SizeInput) => Size;Represents a size in bytes.
Signature
type Size = Brand.Branded<bigint, "Size">;Represents a size in bytes.
Signature
type SizeInput = bigint | number | Size;Signature
declare const TiB: (n: number) => Size;Tag
FileSystem
Added in v1.0.0
Source
Signature
declare const FileSystem: Tag<FileSystem, FileSystem>;Type Id
FileTypeId
Added in v1.0.0
Source
Signature
declare const FileTypeId: unique symbol;FileTypeId type
Added in v1.0.0
Source
Signature
type FileTypeId = typeof FileTypeId;
Create a no-op file system that can be used for testing.