Skip to content
pgte edited this page Dec 30, 2010 · 1 revision

file.write (string, callback)

Appends string to the end of the file.

  • string: the string you want to be appended into the end of the file
  • callback(error, pos, length): called when write is done. if an error occurs, first argument will have the error object. "pos" contains the written file position. "length" contains the written length.

file.rawWrite (string, pos, callback)

Appends string to the end of the file.

  • string: the string you want to be appended into the end of the file.
  • pos: the position of the file you want it written to.
  • callback(error, pos, length): called when write is done. if an error occurs, first argument will have the error object. "pos" contains the written file position. "length" contains the written length.

file.rename (new_name, callback)

Renames the file.

  • new_name: the new name of the file.
  • callback(error): called when rename completes. contains an occurring error on the first argument or null.

file.clear (callback)

Removes all the content of the file.

  • callback(error): called when the clearing completes. contains an occurring error on the first argument or null.

file.fetch (pos, length, callback)

Fetches content of the file between pos and pos + length.

  • callback(error, result): called when fetch completes. On the first argument contains an occurring error or null. Result is the content string.

file.tryRead (pos, length, callback)

Tries to fetch content of the file between pos and pos + length into a buffer.

  • callback(error, buffer, bytesRead): called when trying to read completes. On the first argument contains an occurring error or null.

file.size (callback)

Get the writing position into callback.

  • callback(error, size): called when reading size completes. On the first argument contains an occurring error or null.

file.writtenSize (callback)

Get the file size on disk into callback. This is the actual file size, before flushing.

  • callback(error, size): called when reading size completes. On the first argument contains an occurring error or null.

file.position (pos)

Sets the writing position of the file to pos. Next call to write will start writing from the specified position.

file.end (callback)

Closes the file.

  • callback(error): called when closing the file completes. On the first argument contains an occurring error or null.

file.destroy (callback)

Removes the file.

  • callback(error): called when closing the file completes. On the first argument contains an occurring error or null.