class Io

class Io

lib/io/io.tya:2

Io provides the io/Io standard library API.

Source
# Io provides the io/Io standard library API.
class Io
  # Io.copy provides the io/Io standard library operation.
  # @param reader Any reader value.
  # @param writer Any writer value.
  # @return Any the resulting value.
  copy: reader, writer ->
    total = 0
    chunk = reader.read(8192)
    while chunk != nil and chunk.len() > 0
      total = total + writer.write(chunk)
      chunk = reader.read(8192)
    writer.flush()
    total

  # Io.open provides the io/Io standard library operation.
  # @param path String path value.
  # @param mode Any mode value.
  # @return Any the resulting value.
  open: path, mode = nil ->
    if mode == nil
      mode = "r"
    handle = io_open(path, mode)
    binary = mode.contains("b")
    if mode.contains("r")
      return Reader(handle, binary)
    Writer(handle, binary)

  # Io.stderr provides the io/Io standard library operation.
  # @return Any the resulting value.
  stderr: ->
    Writer(io_stderr(), false)

  # Io.stdin provides the io/Io standard library operation.
  # @return Any the resulting value.
  stdin: ->
    Reader(io_stdin(), false)

  # Io.stdout provides the io/Io standard library operation.
  # @return Any the resulting value.
  stdout: ->
    Writer(io_stdout(), false)

Methods

copy

Io.copy(reader, writer)

lib/io/io.tya:7

Io.copy provides the io/Io standard library operation.

Source
  # Io.copy provides the io/Io standard library operation.
  # @param reader Any reader value.
  # @param writer Any writer value.
  # @return Any the resulting value.
  copy: reader, writer ->
    total = 0
    chunk = reader.read(8192)
    while chunk != nil and chunk.len() > 0
      total = total + writer.write(chunk)
      chunk = reader.read(8192)
    writer.flush()
    total

open

Io.open(path, mode = nil)

lib/io/io.tya:20

Io.open provides the io/Io standard library operation.

Source
  # Io.open provides the io/Io standard library operation.
  # @param path String path value.
  # @param mode Any mode value.
  # @return Any the resulting value.
  open: path, mode = nil ->
    if mode == nil
      mode = "r"
    handle = io_open(path, mode)
    binary = mode.contains("b")
    if mode.contains("r")
      return Reader(handle, binary)
    Writer(handle, binary)

stderr

Io.stderr()

lib/io/io.tya:31

Io.stderr provides the io/Io standard library operation.

Source
  # Io.stderr provides the io/Io standard library operation.
  # @return Any the resulting value.
  stderr: ->
    Writer(io_stderr(), false)

stdin

Io.stdin()

lib/io/io.tya:36

Io.stdin provides the io/Io standard library operation.

Source
  # Io.stdin provides the io/Io standard library operation.
  # @return Any the resulting value.
  stdin: ->
    Reader(io_stdin(), false)

stdout

Io.stdout()

lib/io/io.tya:41

Io.stdout provides the io/Io standard library operation.

Source
  # Io.stdout provides the io/Io standard library operation.
  # @return Any the resulting value.
  stdout: ->
    Writer(io_stdout(), false)