# File (of `Object`)

class `File`

  Defined in File.sc.

  This class encapsulates reading and writing to a file.

  Example usage:

      = myFile (File new:)
      (if (newFile name: "myfile.txt" open: fOPENFAIL)
               ; Read stuff from file, etc...
      )

      ; Close the file.
      (newFile close: dispose:)

## Properties

Inherited from `Object`:

Property | Description
--- | ---
name |

Defined in File:

Property | Description
--- | ---
handle |

## Methods

`dispose`()

`showStr`(param1)

`open`(openMode)

  Opens the file in one of the following modes:

  fOPENCREATE
    Opens the file. If the file doesn’t exist, it is created.
  fOPENFAIL
    Opens the file and fails if it doesn’t exist.
  fCREATE
    Opens the file, deleting any previous content it had.

  Parameters: | openMode (number) – fOPENCREATE, fOPENFAIL or fCREATE. If not specified, fOPENCREATE is used.
  Returns: | The file object if successful, otherwise NULL.

`readString`(buffer maxSize)

  Reads a text string from the file.

  Parameters: | buffer (string) – The buffer into which the text is placed. maxSize (number) – The buffer size.
  Returns: | The number of characters read.

`writeString`(buffer [...])

  Writes a text string (or multiple text strings) to the file.

  Parameters: | buffer (string) – Buffer containing the string. Multiple strings may be provided.

`write`(buffer count)

  Writes data to the file.

  Parameters: | buffer (heapPtr) – Buffer of data to be written. count (number) – The number of bytes in the buffer.
  Returns: | The number of bytes written, or NULL if it failed.

`read`(buffer size)

  Reads data into a buffer.

  Parameters: | buffer (heapPtr) – Buffer into which the data will be read. size (number) – The size in bytes in the buffer.
  Returns: | The number of bytes read, or NULL if it failed.

`seek`(offset whence)

  Seeks to a position in the file.

  Parameters: | offset (number) – Positive or negative offset. whence (number) – 0 to seek from the beginning, 1 to seek from the current position, or 2 to seek from the end.

`close`()

  Closes the file.

`delete`()

  Deletes the file.