8.26. File tom/Descriptor

class tom.Descriptor

A Descriptor is the abstraction of the UNIX file descriptor.

inherits

State supers: State, Conditions

instance tom.Descriptor

variables

public int descriptor;

The file descriptor. This will be -1 if we're not actively open.

methods


void
  close;

Close this descriptor. If it succeeds, every read, write, or other operation afterwards will certainly fail. If it fails, this may not be the case.


void
  dealloc;

Close the descriptor if it is not -1.


id
  init;

Invoke [self init -1] to avoid ever closing file descriptor 0 by accident.


protected id
  init int fd;

Designated initializer: Initialize with fd as the descriptor.


int
  type-of-file;

Return one of the FILE_TYPE_* constants for the receiving File. Signal a file_error and return FILE_TYPE_NONEXISTENT if not open.