LocalFile (class)
public LocalFile {inherits File}
Package: CURL.IO.FILE

A File that exists in the local filesystem.


Constructors
clone-from:Initialize a LocalFile.
constructor public {LocalFile.clone-from from:LocalFile}
Properties
exists?:Indicates whether the file represented by self actually exists in the underlying filesystem.
accessor public LocalFile.exists?:bool
readable?:Indicates whether the object represented by self can be opened for reading.
accessor public LocalFile.readable?:bool
url:The name of this file.
accessor public final inline LocalFile.url:Url
when-last-accessed:Returns when last accessed, if applicable, otherwise null.
accessor public LocalFile.when-last-accessed:#DateTime
when-last-modified:Returns when last modified, if applicable, otherwise null.
accessor public LocalFile.when-last-modified:#DateTime
writable?:Indicates whether the file represented by self can be opened for writing.
accessor public LocalFile.writable?:bool
Properties inherited from File: name, parent-dir
Methods
append-open:Open self for appending.
public {LocalFile.append-open
    create?:bool = true,
    create-mode:int = 0o666,
    character-encoding:CharEncoding = CharEncoding.none-specified,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte }
}:TextOutputStream
append-open-byte:Open self for byte-stream appending.
public {LocalFile.append-open-byte
    create?:bool = true,
    create-mode:int = 0o666,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte }
}:ByteOutputStream
async-read-open:Asynchronously opens self for text input, and calls the provided event handlers with an AsyncFileOpenEvent that contains either an exception or the TextInputStream that was opened in it.
public {LocalFile.async-read-open
    character-encoding:CharEncoding = CharEncoding.none-specified,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, char },
    unread-size:int = {min 4, buffer-size div 4},
    event-handler:EventHandler,
    ...:EventHandler
}:AsyncFileOpener
async-read-open-byte:Asynchronously opens self for byte input, and calls the provided event handlers with an AsyncFileOpenEvent that contains either an exception or the ByteInputStream that was opened in it.
public {LocalFile.async-read-open-byte
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte },
    unread-size:int = {min 4, buffer-size div 4},
    event-handler:EventHandler,
    ...:EventHandler
}:AsyncFileOpener
clone:Returns a shallow copy of self.
public {LocalFile.clone}:LocalFile
info:Returns a LocalFileInfo object, which lets you access more information about the File.
public {LocalFile.info
    snap-symlink?:bool = true,
    error-if-missing?:bool = true
}:#LocalFileInfo
read-open:Open self for input.
public {LocalFile.read-open
    character-encoding:CharEncoding = CharEncoding.none-specified,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, char },
    unread-size:int = {min 4, buffer-size div 4}
}:TextInputStream
read-open-byte:Open self for byte-stream input.
public {LocalFile.read-open-byte
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte },
    unread-size:int = {min 4, buffer-size div 4}
}:ByteInputStream
write-open:Open self for output.
public {LocalFile.write-open
    create?:bool = true,
    create-mode:int = 0o666,
    error-if-exists?:bool = false,
    truncate-if-exists?:bool = true,
    character-encoding:CharEncoding = CharEncoding.none-specified,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte }
}:TextOutputStream
write-open-byte:Open self for byte-stream output.
public {LocalFile.write-open-byte
    create?:bool = true,
    create-mode:int = 0o666,
    error-if-exists?:bool = false,
    truncate-if-exists?:bool = true,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte }
}:ByteOutputStream
Methods inherited from Object: object-describe, object-describe-for-debugging, object-serialize

Constructor Details
clone-from (constructor)
public {LocalFile.clone-from from:LocalFile}

Initialize a LocalFile.

from: self's name is copied from from.


Property Details
exists? (accessor)
accessor public LocalFile.exists?:bool

Indicates whether the file represented by self actually exists in the underlying filesystem.

Returns

A bool indicating whether the file exists or not.

Description

The returned value is not a guarantee that any future action on self will succeed or fail in any particular way. Many factors (including race conditions, permission issues, and platform limitations) prevent perfect accuracy. In addition the implementation may choose to improve performance by reducing the accuracy of the result.


readable? (accessor)
accessor public LocalFile.readable?:bool

Indicates whether the object represented by self can be opened for reading.

Returns

A bool indicating whether the object is readable or not.

Description

The returned value is not a guarantee that any future action on self will succeed or fail in any particular way. Many factors (including race conditions, permission issues, and platform limitations) prevent perfect accuracy. In addition the implementation may choose to improve performance by reducing the accuracy of the result.


url (accessor)
accessor public final inline LocalFile.url:Url

The name of this file.



when-last-accessed (accessor)
accessor public LocalFile.when-last-accessed:#DateTime

Returns when last accessed, if applicable, otherwise null.



when-last-modified (accessor)
accessor public LocalFile.when-last-modified:#DateTime

Returns when last modified, if applicable, otherwise null.



writable? (accessor)
accessor public LocalFile.writable?:bool

Indicates whether the file represented by self can be opened for writing.

Returns

A bool indicating whether the file is writable or not.

Description

The returned value is not a guarantee that any future action on self will succeed or fail in any particular way. Many factors (including race conditions, permission issues, and platform limitations) prevent perfect accuracy. In addition the implementation may choose to improve performance by reducing the accuracy of the result.


Method Details
append-open (method)
public {LocalFile.append-open
    create?:bool = true,
    create-mode:int = 0o666,
    character-encoding:CharEncoding = CharEncoding.none-specified,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte }
}:TextOutputStream

Open self for appending.

create?: When true (default), indicates that the underlying file should be created if it doesn't already exist.
create-mode: Indicates the permissions that the file should have, if created. Currently, on UNIX systems, this argument is simply passed directly through to open() and mkdir() calls. On UNIX systems, create-mode is modified by the umask to get the resulting file protection.
character-encoding: Indicates the character encoding to use when writing to the file. See CharEncoding. When unspecified, the character encoding is determined as in File.read-open.
buffer-size: Minimum number of chars to be buffered. If buffer-size is 0, tries to make an unbuffered stream if possible.

Returns

Returns the TextOutputStream it opens.

Notes

Usually, trying to seek on the TextOutputStream that this method returns will fail.

Notes

The stream returned does not do any kind of newline processing. A NewlineFilterTextOutputStream or SeekableNewlineFilterTextOutputStream can be used to wrap the returned stream if newline processing is desired.


append-open-byte (method)
public {LocalFile.append-open-byte
    create?:bool = true,
    create-mode:int = 0o666,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte }
}:ByteOutputStream

Open self for byte-stream appending.

create?: When true (default), indicates that the underlying file should be created if it doesn't already exist.
create-mode: Indicates the permissions that the file should have, if created. Currently, on UNIX systems, this argument is simply passed directly through to open() and mkdir() calls. On UNIX systems, create-mode is modified by the umask to get the resulting file protection.
buffer-size: Minimum number of chars to be buffered. If buffer-size is 0, tries to make an unbuffered stream if possible; if not 0, a BufferedByteOutputStream will be returned.

Returns

Returns the ByteOutputStream it opens.

Notes

Usually, trying to seek on the ByteOutputStream that this method returns will fail.


async-read-open (method)
public {LocalFile.async-read-open
    character-encoding:CharEncoding = CharEncoding.none-specified,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, char },
    unread-size:int = {min 4, buffer-size div 4},
    event-handler:EventHandler,
    ...:EventHandler
}:AsyncFileOpener

Asynchronously opens self for text input, and calls the provided event handlers with an AsyncFileOpenEvent that contains either an exception or the TextInputStream that was opened in it.

character-encoding: Indicates the character encoding to use when reading from the file. See CharEncoding. If unspecified, the character encoding is interpreted, if possible, from the first few bytes in the stream. When this is not possible, the default character encoding, CharEncoding.utf8, is used.
buffer-size: Minimum number of chars to be buffered. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.
unread-size: Minimum number of chars to be efficiently unreadable. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.
event-handler: EventHandler that must take a AsyncFileOpenEvent, at least one must be provided.
...: More optional EventHandlers that must take a AsyncFileOpenEvent.

Returns

Returns the AsyncFileOpener which can control the asynchronous open.


async-read-open-byte (method)
public {LocalFile.async-read-open-byte
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte },
    unread-size:int = {min 4, buffer-size div 4},
    event-handler:EventHandler,
    ...:EventHandler
}:AsyncFileOpener

Asynchronously opens self for byte input, and calls the provided event handlers with an AsyncFileOpenEvent that contains either an exception or the ByteInputStream that was opened in it.

buffer-size: Minimum number of chars to be buffered. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible; if either is not 0, a BufferedByteInputStream will be made.
unread-size: Minimum number of chars to be efficiently unreadable. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible; if either is not 0, a BufferedByteInputStream will be made.
event-handler: EventHandler that must take a AsyncFileOpenEvent, at least one must be provided.
...: More optional EventHandlers that must take a AsyncFileOpenEvent.

Returns

Returns the AsyncFileOpener which can control the asynchronous open.


clone (method)
public {LocalFile.clone}:LocalFile

Returns a shallow copy of self.



info (method)
public {LocalFile.info
    snap-symlink?:bool = true,
    error-if-missing?:bool = true
}:#LocalFileInfo

Returns a LocalFileInfo object, which lets you access more information about the File.

snap-symlink?: If true, resolves symbolic links in the file's path before creating the LocalFileInfo object.
error-if-missing?: If true, results in a MissingFileException being thrown if the File object does not represent a file that exists in the filesystem.


read-open (method)
public {LocalFile.read-open
    character-encoding:CharEncoding = CharEncoding.none-specified,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, char },
    unread-size:int = {min 4, buffer-size div 4}
}:TextInputStream

Open self for input.

character-encoding: Indicates the character encoding to use when reading from the file. See CharEncoding. If unspecified, the character encoding is interpreted, if possible, from the first few bytes in the stream. When this is not possible, the default character encoding, CharEncoding.utf8, is used.
buffer-size: Minimum number of chars to be buffered. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.
unread-size: Minimum number of chars to be efficiently unreadable. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.

Returns

Returns the TextInputStream it opens.

Notes

The stream returned does not do any kind of newline processing. A NewlineFilterTextInputStream or SeekableNewlineFilterTextInputStream can be used to wrap the returned stream if newline processing is desired.


read-open-byte (method)
public {LocalFile.read-open-byte
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte },
    unread-size:int = {min 4, buffer-size div 4}
}:ByteInputStream

Open self for byte-stream input.

buffer-size: Minimum number of chars to be buffered. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible; if either is not 0, a BufferedByteInputStream will be returned.
unread-size: Minimum number of chars to be efficiently unreadable. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible; if either is not 0, a BufferedByteInputStream will be returned.

Returns

Returns the ByteInputStream it opens.


write-open (method)
public {LocalFile.write-open
    create?:bool = true,
    create-mode:int = 0o666,
    error-if-exists?:bool = false,
    truncate-if-exists?:bool = true,
    character-encoding:CharEncoding = CharEncoding.none-specified,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte }
}:TextOutputStream

Open self for output.

create?: When true (default), indicates that the underlying file should be created if it doesn't already exist.
create-mode: Indicates the permissions that the file should have, if created. Currently, on UNIX systems, this argument is simply passed directly through to open() and mkdir() calls. On UNIX systems, create-mode is modified by the umask to get the resulting file protection.
error-if-exists?: When true, causes this method to throw an ExistingFileException if the file being opened already exists.
truncate-if-exists?: When true (default), indicates that the underlying file should be truncated if it already exists. When false, data will be written to the file from the current location, without truncating the file. The initial location is always the start of the file.
character-encoding: Indicates the character encoding to use when writing to the file. See CharEncoding. If unspecified, the default character encoding, CharEncoding.utf8, is used.
buffer-size: Minimum number of chars to be buffered. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.

Returns

Returns the TextOutputStream it opens.

Notes

create? = false and error-if-exists? = true don't make any sense together.

Notes

See also File.append-open.

Notes

The stream returned does not do any kind of newline processing. A NewlineFilterTextOutputStream or SeekableNewlineFilterTextOutputStream can be used to wrap the returned stream if newline processing is desired.


write-open-byte (method)
public {LocalFile.write-open-byte
    create?:bool = true,
    create-mode:int = 0o666,
    error-if-exists?:bool = false,
    truncate-if-exists?:bool = true,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, byte }
}:ByteOutputStream

Open self for byte-stream output.

create?: When true (default), indicates that the underlying file should be created if it doesn't already exist.
create-mode: Indicates the permissions that the file should have, if created. Currently, on UNIX systems, this argument is simply passed directly through to open() and mkdir() calls. On UNIX systems, create-mode is modified by the umask to get the resulting file protection.
error-if-exists?: When true, causes this method to throw an ExistingFileException if the file being opened already exists.
truncate-if-exists?: When true (defaults), indicates that the underlying file should be truncated if it already exists. When false, data will be written to the file from the current location, without truncating the file. The initial location is always the start of the file.
buffer-size: Minimum number of chars to be buffered. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible; if either is not 0, a BufferedByteOutputStream will be returned.

Returns

Returns the ByteOutputStream it opens.

Notes

create?=false and error-if-exists?=true don't make any sense together.

Notes

See also File.append-open-byte.