FD

FD

FD wraps an integer representing a file descriptor. Usually you don't create these directly but get them through calling other methods like File.open-w().

close

method close()

Closes redirection for this file descriptor.

dup

method dup(FD $new-fd)

Duplicate the invocant file descriptor into the argument file descriptor like DUP(2) if the argument file descriptor is open it will be closed before becoming the alias.

ParameterDescription
$new-fdThe file descriptor to use as the alias

get

method get( ⟶ Bool)

Reads all data up to and including the next newline or up to the EOF and puts it into $~. The newline (if any) will be discarded.

getc

method getc(Int $n ⟶ Bool)

Reads a fixed number of characters

ParameterDescription
$nThe number of characters to read

is-open

method is-open( ⟶ Bool)

Returns True if the file descriptor is open.

next-free

method next-free( ⟶ FD)

Returns the next free file descriptor if it can find one. Dies if it can't.

open-r

method open-r(File $file)

Opens a file for reading from this file descriptor.

ParameterDescription
$fileThe file to open

open-w

method open-w(File $file)

Opens a file for writing from this file descriptor.

ParameterDescription
$fileThe file to redirect to

tty

method tty( ⟶ Bool)

Returns whether this file descriptor is linked to a terminal.

say $*OUT.tty;  #probably true
say FD<42>.tty; #probably false

write

method write(Str $data)

Writes to the file descriptor.

ParameterDescription
$dataThe data to write to the file descriptor

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.