(method: string)
| 193 | // == open |
| 194 | |
| 195 | const openFactory = (method: string): FileSystem.FileSystem["open"] => { |
| 196 | const nodeOpen = effectify( |
| 197 | NFS.open, |
| 198 | handleErrnoException("FileSystem", method), |
| 199 | handleBadArgument(method) |
| 200 | ) |
| 201 | const nodeClose = effectify( |
| 202 | NFS.close, |
| 203 | handleErrnoException("FileSystem", method), |
| 204 | handleBadArgument(method) |
| 205 | ) |
| 206 | |
| 207 | return (path, options) => |
| 208 | pipe( |
| 209 | Effect.acquireRelease( |
| 210 | nodeOpen(path, options?.flag ?? "r", options?.mode), |
| 211 | (fd) => Effect.orDie(nodeClose(fd)) |
| 212 | ), |
| 213 | Effect.map((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false)) |
| 214 | ) |
| 215 | } |
| 216 | const open = openFactory("open") |
| 217 | |
| 218 | const makeFile = (() => { |
no test coverage detected