Libraries anvil io

namespace io
Provides for system input and output through data streams, serialization and the file system.

Classes

class File
extends anvil.lang.object
A representation of file and directory pathnames.

class InputStream
extends anvil.lang.object
Datatype representing an input stream of bytes.

class OutputStream
extends anvil.lang.object
This class represents an output stream of bytes

class Process
extends anvil.lang.object
Native process created by exec.


Exceptions

class EndOfFile
extends anvil.io.IOError

class FileNotFound
extends anvil.io.IOError

class InterruptedIO
extends anvil.io.IOError

class IOError
extends anvil.lang.throwable

class SyncFailed
extends anvil.io.IOError


Constants

constant pathSeparator
The system-dependent default name-separator character.

constant separator
The system-dependent path-separator character.


Functions

File createTempFile(string prefix, string suffix)
File createTempFile(string prefix, string suffix, File path)
File createTempFile(string prefix, string suffix, string path)
Creates temporary file with given 'prefix' and 'suffix' to optional 'path'. If path is omitted system's default temporary directory is used.
Parameters prefix -  Prefix of created file
suffix -  Suffix of create file
path -  Path into which the file is created
Returns Temporary file
Throws IOError -  If an I/O error occurs

Process exec(sequence arguments)
Process exec(sequence arguments, array environment)
Executes given command and return process datatype.
Parameters arguments -  Sequence of arguments
environment -  Process environment
Returns a process datatype

tuple getImageSize(File image)
Returns tuple (contentType, width, height, color) for GIF, PNG and JPEG images. If the size cannot be determined returns undefined.
Throws IOError -  If an I/O error occurs

InputStream inputFrom(object sentinel)
Returns an InputStream that will loop through the elements of iterator. Given an element of type:

list listRoots()
Lists all the file system roots of the system.
Returns List of Files

object load(File file)
object load(string file)
Loads serialized data from file.
Parameters file -  File to load from
Throws CorruptedSerialization -  If serialized data is corrupted.
IOError -  If an I/O error occurs

OutputStream outputTo(object handler)
Returns an OutputStream that will send content to given handler. Handler must implement following operations:

int passthru(sequence arguments)
int passthru(sequence arguments, array environment)
Executes given command and prints its output.
Parameters arguments -  Sequence of arguments
environment -  Process environment
Returns the exit value returned by the command

string readText(File file)
string readText(string file)
Reads the contents of a file into a text string.
Parameters file -  File to read
Throws IOError -  If an I/O error occurs

boolean save(File file, object data)
boolean save(string file, object data)
Serializes data to file.
Parameters file -  Filename to save to
data -  Data to serialize
Throws IOError -  If an I/O error occurs