(path: string | URL, options?: OpenOptions)
| 170 | * @returns A {@linkcode FsFile} instance. |
| 171 | */ |
| 172 | export function openSync(path: string | URL, options?: OpenOptions): FsFile { |
| 173 | if (isDeno) { |
| 174 | return Deno.openSync(path, options); |
| 175 | } else { |
| 176 | const { |
| 177 | read = true, |
| 178 | write = false, |
| 179 | append = false, |
| 180 | truncate = false, |
| 181 | create = false, |
| 182 | createNew = false, |
| 183 | mode = 0o666, |
| 184 | } = options ?? {}; |
| 185 | |
| 186 | try { |
| 187 | const flag = getOpenFsFlag({ |
| 188 | read, |
| 189 | write, |
| 190 | append, |
| 191 | truncate, |
| 192 | create, |
| 193 | createNew, |
| 194 | }); |
| 195 | |
| 196 | const fd = getNodeFs().openSync(path, flag, mode); |
| 197 | return new NodeFsFile(fd) as FsFile; |
| 198 | } catch (error) { |
| 199 | throw mapError(error); |
| 200 | } |
| 201 | } |
| 202 | } |
no test coverage detected