Class FileFlag

Represents one of the following file flags. A convenience object.

  • 'r' - Open file for reading. An exception occurs if the file does not exist.
  • 'r+' - Open file for reading and writing. An exception occurs if the file does not exist.
  • 'rs' - Open file for reading in synchronous mode. Instructs the filesystem to not cache writes.
  • 'rs+' - Open file for reading and writing, and opens the file in synchronous mode.
  • 'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
  • 'wx' - Like 'w' but opens the file in exclusive mode.
  • 'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
  • 'wx+' - Like 'w+' but opens the file in exclusive mode.
  • 'a' - Open file for appending. The file is created if it does not exist.
  • 'ax' - Like 'a' but opens the file in exclusive mode.
  • 'a+' - Open file for reading and appending. The file is created if it does not exist.
  • 'ax+' - Like 'a+' but opens the file in exclusive mode.

Exclusive mode ensures that the file path is newly created.

Hierarchy

  • FileFlag

Constructors

  • This should never be called directly.

    Parameters

    • flag: string | number

      The string or number representing the flag

    Returns FileFlag

    Throw

    when the flag is invalid

Properties

flagStr: string
flagCache: Map<string | number, FileFlag> = ...
validFlagStrs: string[] = ...

Methods

  • Get the underlying flag string for this flag.

    Returns string

  • Get the equivalent mode (0b0xxx: read, write, execute) Note: Execute will always be 0

    Returns number

  • Returns true if the file is appendable.

    Returns boolean

  • Returns true if the file is open in exclusive mode.

    Returns boolean

  • Returns true if the file is readable.

    Returns boolean

  • Returns true if the file is open in synchronous mode.

    Returns boolean

  • Returns true if the file mode should truncate.

    Returns boolean

  • Returns true if the file is writeable.

    Returns boolean

  • Returns one of the static fields on this object that indicates the appropriate response to the path existing.

    Returns ActionType

  • Returns one of the static fields on this object that indicates the appropriate response to the path not existing.

    Returns ActionType

  • Parameters

    • flag: number

      The number representing the flag

    Returns string

    The string representing the flag

    Throw

    when the flag number is invalid

  • Get an object representing the given file flag.

    Parameters

    • flag: string | number

      The string or number representing the flag

    Returns FileFlag

    The FileFlag object representing the flag

    Throw

    when the flag string is invalid

Generated using TypeDoc