-
Notifications
You must be signed in to change notification settings - Fork 2
/
os.d.ts
144 lines (134 loc) · 4.58 KB
/
os.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
declare module "os" {
import { Seek, Error } from "std";
type Success = 0;
type OSOperationResult = Success | Error;
type OSOperationTuple = [str: string, error: OSOperationResult];
type Callback = () => any;
type TimeoutHandle = number;
export interface File {
close(): number;
puts(str: string): void;
printf(fmt: string, ...args: any[]): void;
flush(): void;
seek(offset: number, whence: Seek): number;
tell(): number;
tello(): BigInt;
eof(): boolean | unknown;
fileno(): unknown;
error(): Error | unknown;
clearerr(): void;
read(buffer: ArrayBuffer, position: number, length: number): void;
write(buffer: ArrayBuffer, position: number, length: number): void;
getline(): string;
readAsString(max_size?: number): string;
getByte(): number;
putByte(c: number): void;
}
export interface FileStatus {
readonly dev: number;
readonly ino: number;
readonly mode: number;
readonly nlink: number;
readonly uid: number;
readonly gid: number;
readonly rdev: number;
readonly size: number;
readonly blocks: number;
readonly atime: number;
readonly mtime: number;
readonly ctime: number;
}
export interface ExecOptions {
block?: boolean;
usePath?: boolean;
file?: string;
cwd?: string;
stdin?: File;
stdout?: File;
stderr?: File;
env?: { readonly [key: string]: string };
uid?: number;
gid?: number;
}
export class Worker {
static parent: Worker;
constructor(filename: string);
postMessage(msg: any): void;
onmessage: (data: any) => void | null;
}
export const SIGINT: 2;
export const SIGABRT: 6;
export const SIGFPE: 8;
export const SIGILL: 4;
export const SIGSEGV: 11;
export const SIGTERM: 15;
export const WNOHANG: 1;
export const platform: "linux" | "darwin" | "win32" | "js";
export const O_RDONLY: 0;
export const O_WRONLY: 1;
export const O_RDWR: 2;
export const O_CREAT: 64;
export const O_EXCL: 128;
export const O_TRUNC: 512;
export const O_APPEND: 1024;
export function open(filename: string, flag: number, mode?: unknown): File | -1;
export function close(file: File): number;
export function seek(file: File, offset: number, whence: Seek): number;
export function seek(
file: File,
offset: BigInt,
whence: Seek
): BigInt;
export function read(
file: File,
buffer: ArrayBuffer,
offset: number,
length: number
): number;
export function write(
file: File,
buffer: ArrayBuffer,
offset: number,
length: number
): number;
export function isatty(file: File): boolean;
export function ttyGetWinSize(
file: File
): [width: number, height: number] | null;
export function ttySetRaw(file: File): void;
export function remove(filename: string): OSOperationResult;
export function rename(oldname: string, newname: string): OSOperationResult;
export function realpath(path: string): OSOperationTuple;
export function getcwd(): OSOperationTuple;
export function chdir(path: string): OSOperationResult;
export function mkdir(path: string, mode?: string): OSOperationResult;
export function stat(path: string): [status: FileStatus, error: Error];
export function lstat(path: string): [status: FileStatus, error: Error];
export function utimes(
path: string,
atime: number,
mtime: number
): OSOperationResult;
export function symlink(target: string, linkpath: string): OSOperationResult;
export function readlink(path: string): OSOperationTuple;
export function readdir(path: string): [files: string[], error: Error];
export function setReadHandler(file: File, cb: Callback | null): void;
export function setReadHandler(file: File, cb: null): void;
export function setWriteHandler(file: File, cb: Callback): void;
export function setWriteHandler(file: File, cb: null): void;
export function signal(signal: number, cb: Callback): void;
export function signal(signal: number, cb: null): void;
export function signal(signal: number, cb: undefined): void;
export function kill(pid: number, signal: number): void;
export function exec(args: string[], options?: ExecOptions): number;
export function waitpid(
pid: number,
options: number
): [ret: unknown | Error, status: any];
export function dup(file: File): void;
export function dup2(oldFile: File, newFile: File): void;
export function pipe(): [readFile: File, writeFile: File] | null;
export function sleep(delay: number): void;
export function setTimeout(cb: Callback, delay: number): TimeoutHandle;
export function clearTimeout(handle: TimeoutHandle): void;
}