(method: string)
| 261 | }) |
| 262 | |
| 263 | const openFactory = (method: string): FileSystem.FileSystem["open"] => { |
| 264 | const nodeOpen = effectify( |
| 265 | NFS.open, |
| 266 | handleErrnoException("FileSystem", method), |
| 267 | handleBadArgument(method) |
| 268 | ) |
| 269 | const nodeClose = effectify( |
| 270 | NFS.close, |
| 271 | handleErrnoException("FileSystem", method), |
| 272 | handleBadArgument(method) |
| 273 | ) |
| 274 | |
| 275 | return (path, options) => |
| 276 | pipe( |
| 277 | Effect.acquireRelease( |
| 278 | options?.noFollow === true |
| 279 | ? Effect.flatMap(noFollowFlags(method, options.flag ?? "r"), (flags) => nodeOpen(path, flags, options.mode)) |
| 280 | : nodeOpen(path, options?.flag ?? "r", options?.mode), |
| 281 | (fd) => Effect.orDie(nodeClose(fd)) |
| 282 | ), |
| 283 | Effect.map((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false)) |
| 284 | ) |
| 285 | } |
| 286 | const open = openFactory("open") |
| 287 | |
| 288 | const isEspipe = (error: Error.PlatformError) => |
no test coverage detected