Skip to content
File

Blob: src/node/internal/filesystem.d.ts

typescript122 lines
1// Copyright (c) 2026 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5export interface StatOptions {
6 followSymlinks?: boolean;
7}
8 
9export interface Stat {
10 type: 'file' | 'directory' | 'symlink';
11 size: number;
12 lastModified: bigint;
13 created: bigint;
14 writable: boolean;
15 device: boolean;
16}
17 
18export function stat(pathOrFd: number | URL, options: StatOptions): Stat | null;
19export function setLastModified(
20 pathOrFd: number | URL,
21 mtime: Date,
22 options: StatOptions
23): void;
24 
25export function truncate(pathOrFd: number | URL, length: number): void;
26 
27export function readLink(
28 path: URL,
29 options: { failIfNotSymlink: boolean }
30): string;
31 
32export function link(from: URL, to: URL, options: { symbolic: boolean }): void;
33 
34export function unlink(path: URL): void;
35 
36export function open(
37 path: URL,
38 options: {
39 read: boolean;
40 write: boolean;
41 append: boolean;
42 exclusive: boolean;
43 followSymlinks: boolean;
44 }
45): number;
46 
47export function close(fd: number): void;
48 
49export function write(
50 fd: number,
51 buffers: ArrayBufferView[],
52 options: {
53 position: number | bigint | null;
54 }
55): number;
56 
57export function read(
58 fd: number,
59 buffers: ArrayBufferView[],
60 options: {
61 position: number | bigint | null;
62 }
63): number;
64 
65export function readAll(pathOrFd: number | URL): Uint8Array;
66 
67export function writeAll(
68 pathOrFd: number | URL,
69 data: ArrayBufferView,
70 options: { append: boolean; exclusive: boolean }
71): number;
72 
73export function renameOrCopy(
74 from: URL,
75 to: URL,
76 options: { copy: boolean }
77): void;
78 
79export function mkdir(
80 path: URL,
81 options: { recursive: boolean; tmp: boolean }
82): string | undefined;
83 
84export function rm(
85 path: URL,
86 options: { recursive: boolean; force: boolean; dironly: boolean }
87): void;
88 
89export interface DirEntryHandle {
90 name: string;
91 parentPath: string;
92 type: number;
93}
94 
95export function readdir(
96 path: URL,
97 options: { recursive: boolean }
98): DirEntryHandle[];
99 
100export function cp(
101 src: URL,
102 dest: URL,
103 options: {
104 deferenceSymlinks: boolean;
105 recursive: boolean;
106 force: boolean;
107 errorOnExist: boolean;
108 }
109): void;
110 
111interface FdHandle {
112 close(): void;
113}
114 
115export function getFdHandle(fd: number): FdHandle;
116 
117export interface OpenAsBlobOptions {
118 type?: string | undefined;
119}
120 
121export function openAsBlob(path: URL, options: OpenAsBlobOptions): Blob;