shadow:io

Class File

Parent class

shadow:standard@Object

Interfaces

shadow:io@CanRead, shadow:io@CanWrite, shadow:io@CanOpen, shadow:io@CanClose

class File

Class File provides utilities for interacting with a file in the operating system, such as creating a new file, deleting an existing file, reading from a file, and writing to a file.

Create Summary

Modifiers Return Types Method and Description
public () create(Path path)

Creates a File object associated with the file specified by the given Path object.

public () create(String path)

Creates a File object associated with the file on the given path.

Destroy Summary

Modifiers Return Types Method and Description
public () destroy()

Closes the File on destroy.

Method Summary

Modifiers Return Types Method and Description
public () close()

Closes the file.

public readonly (File) copy(AddressMap addresses)
public (File) delete()
public () open()

Opens or creates a file in the operating system with the path of this File object.

public () open(int mode)

Opens or creates a file in the operating system with the path of this File object.

public readonly (long) read(ubyte[] buffer)

Reads data from the file into the buffer and updates the read pointer location.

public readonly (String) toString()

Returns a String representation of the path of this file.

public (long) write(readonly ubyte[] buffer, long bytes)

Writes data from the buffer into the file and updates the write pointer location.

Property Summary

Modifiers Return Types Method and Description
public readonly get (boolean) exists()

Determines a file in the operating system matches the path in this File object.

public get (boolean) isOpen()

Gets whether the file is open.

public readonly get (Path) path()
public readonly get (long) position()

Gets the current position of the read/write pointer inside the file.

public set () position(long position)

Sets the current position of the read/write pointer inside the file.

public readonly get (long) size()

Gets the size of the file in bytes.

public set () size(long size)

Sets the size of the file in bytes, extending or truncating it.

Create Detail

create

public create(Path path) => ()

Creates a File object associated with the file specified by the given Path object.

Parameters

path - of the file

create

public create(String path) => ()

Creates a File object associated with the file on the given path.

Parameters

path - of the file

Destroy Detail

destroy

public destroy() => ()

Closes the File on destroy.

Method Detail

close

public close() => ()

Closes the file.

copy

public readonly copy(AddressMap addresses) => (File)

delete

public delete() => (File)

open

public open() => ()

Opens or creates a file in the operating system with the path of this File object.

open

public open(int mode) => ()

Opens or creates a file in the operating system with the path of this File object.

read

public readonly read(ubyte[] buffer) => (long)

Reads data from the file into the buffer and updates the read pointer location.

Parameters

buffer - array of byte values to hold file data

Returns

number of byte values successfully read, always less than or equal the length of the buffer, or -1 if end of file has been reached

toString

public readonly toString() => (String)

Returns a String representation of the path of this file.

write

public write(readonly ubyte[] buffer, long bytes) => (long)

Writes data from the buffer into the file and updates the write pointer location.

Parameters

buffer - array of ubyte values to be written

bytes - total number of bytes to write

Returns

number of byte values successfully written

Property Detail

exists

public readonly get exists() => (boolean)

Determines a file in the operating system matches the path in this File object.

Returns

true if the file exists

isOpen

public get isOpen() => (boolean)

Gets whether the file is open. This method does not distinguish between open for reading and open for writing.

path

public readonly get path() => (Path)

position

public readonly get position() => (long)

Gets the current position of the read/write pointer inside the file.

Returns

position in file

position

public set position(long position) => ()

Sets the current position of the read/write pointer inside the file.

Parameters

position - in file

size

public readonly get size() => (long)

Gets the size of the file in bytes.

Returns

file size

size

public set size(long size) => ()

Sets the size of the file in bytes, extending or truncating it.

Parameters

new - file size