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.
| Parameter | Description | 
| $new-fd | The 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
Reads a fixed number of characters
| Parameter | Description | 
| $n | The 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.
| Parameter | Description | 
| $file | The file to open | 
open-w
method open-w(File $file)
Opens a file for writing from this file descriptor.
| Parameter | Description | 
| $file | The 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 falsewrite
method write(Str $data)
Writes to the file descriptor.
| Parameter | Description | 
| $data | The data to write to the file descriptor |