effect-io-ai

Package: effect
Module: FileSystem

FileSystem.OpenFlag

File open flags that determine how a file is opened and what operations are allowed.

Details

These flags correspond to standard POSIX file open modes and control the file access permissions and behavior when opening files.

Example (Opening files with flags)

import { Effect, FileSystem } from "effect"

const program = Effect.gen(function*() {
  const fs = yield* FileSystem.FileSystem

  // Open for reading only
  const readFile = yield* fs.open("data.txt", { flag: "r" })

  // Open for writing, truncating existing content
  const writeFile = yield* fs.open("output.txt", { flag: "w" })

  // Open for appending
  const appendFile = yield* fs.open("log.txt", { flag: "a" })

  // Open for read/write, but fail if file doesn't exist
  const editFile = yield* fs.open("config.json", { flag: "r+" })
})

Signature

type OpenFlag = | "r"
  | "r+"
  | "w"
  | "wx"
  | "w+"
  | "wx+"
  | "a"
  | "ax"
  | "a+"
  | "ax+"

Source

Since v4.0.0