Function open

  • Asynchronous file open. Exclusive mode ensures that path is newly created. Mode defaults to 0644

    flags can be:

    • '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.

    Parameters

    • path: PathLike
    • flag: string
    • Optionalcb: Callback<[number]>

    Returns void

  • Parameters

    • path: PathLike
    • flag: string
    • mode: string | number
    • Optionalcb: Callback<[number]>

    Returns void