Skip to content

infinity.fileMode

Provides enums for file access modes.

Module: none (built-in)

Enums:

Enums

infinity.fileMode

Used e.g. by the infinity.stream constructor. An access mode (create, read, write or readWrite) can be combined with a sharing mode (shareExclusive, shareDenyWrite or shareDenyNone) using |.

Values:

  • create: 65280

    Creates the file (opened for reading and writing). An existing file is overwritten.

  • read: 0

    Opens the file for reading only.

  • write: 1

    Opens the file for writing only.

  • readWrite: 2

    Opens the file for reading and writing.

  • exclusive: 4

    Combined with create: creates the file only if it does not exist yet, fails otherwise.

  • shareExclusive: 16

    Denies read and write access to all others.

  • shareDenyWrite: 32

    Denies write access to all others.

  • shareDenyNone: 64 (Windows), 48 (Linux, macOS)

    No sharing restrictions.

Example:

infinity.loadModule('infinity.stream');
let fileStream = new infinity.stream('data.bin', infinity.fileMode.create | infinity.fileMode.shareDenyWrite);
fileStream.free();