File
Blob: src/node/internal/filesystem.d.ts
| 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 | |
| 5 | export interface StatOptions { |
| 6 | followSymlinks?: boolean; |
| 7 | } |
| 8 | |
| 9 | export interface Stat { |
| 10 | type: 'file' | 'directory' | 'symlink'; |
| 11 | size: number; |
| 12 | lastModified: bigint; |
| 13 | created: bigint; |
| 14 | writable: boolean; |
| 15 | device: boolean; |
| 16 | } |
| 17 | |
| 18 | export function stat(pathOrFd: number | URL, options: StatOptions): Stat | null; |
| 19 | export function setLastModified( |
| 20 | pathOrFd: number | URL, |
| 21 | mtime: Date, |
| 22 | options: StatOptions |
| 23 | ): void; |
| 24 | |
| 25 | export function truncate(pathOrFd: number | URL, length: number): void; |
| 26 | |
| 27 | export function readLink( |
| 28 | path: URL, |
| 29 | options: { failIfNotSymlink: boolean } |
| 30 | ): string; |
| 31 | |
| 32 | export function link(from: URL, to: URL, options: { symbolic: boolean }): void; |
| 33 | |
| 34 | export function unlink(path: URL): void; |
| 35 | |
| 36 | export 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 | |
| 47 | export function close(fd: number): void; |
| 48 | |
| 49 | export function write( |
| 50 | fd: number, |
| 51 | buffers: ArrayBufferView[], |
| 52 | options: { |
| 53 | position: number | bigint | null; |
| 54 | } |
| 55 | ): number; |
| 56 | |
| 57 | export function read( |
| 58 | fd: number, |
| 59 | buffers: ArrayBufferView[], |
| 60 | options: { |
| 61 | position: number | bigint | null; |
| 62 | } |
| 63 | ): number; |
| 64 | |
| 65 | export function readAll(pathOrFd: number | URL): Uint8Array; |
| 66 | |
| 67 | export function writeAll( |
| 68 | pathOrFd: number | URL, |
| 69 | data: ArrayBufferView, |
| 70 | options: { append: boolean; exclusive: boolean } |
| 71 | ): number; |
| 72 | |
| 73 | export function renameOrCopy( |
| 74 | from: URL, |
| 75 | to: URL, |
| 76 | options: { copy: boolean } |
| 77 | ): void; |
| 78 | |
| 79 | export function mkdir( |
| 80 | path: URL, |
| 81 | options: { recursive: boolean; tmp: boolean } |
| 82 | ): string | undefined; |
| 83 | |
| 84 | export function rm( |
| 85 | path: URL, |
| 86 | options: { recursive: boolean; force: boolean; dironly: boolean } |
| 87 | ): void; |
| 88 | |
| 89 | export interface DirEntryHandle { |
| 90 | name: string; |
| 91 | parentPath: string; |
| 92 | type: number; |
| 93 | } |
| 94 | |
| 95 | export function readdir( |
| 96 | path: URL, |
| 97 | options: { recursive: boolean } |
| 98 | ): DirEntryHandle[]; |
| 99 | |
| 100 | export 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 | |
| 111 | interface FdHandle { |
| 112 | close(): void; |
| 113 | } |
| 114 | |
| 115 | export function getFdHandle(fd: number): FdHandle; |
| 116 | |
| 117 | export interface OpenAsBlobOptions { |
| 118 | type?: string | undefined; |
| 119 | } |
| 120 | |
| 121 | export function openAsBlob(path: URL, options: OpenAsBlobOptions): Blob; |