Package ghidra.pcode.emu.unix

# Class IOStreamEmuUnixFileHandle

java.lang.Object
ghidra.pcode.emu.unix.AbstractStreamEmuUnixFileHandle<byte[]>
ghidra.pcode.emu.unix.IOStreamEmuUnixFileHandle

All Implemented Interfaces:
  `EmuUnixFileDescriptor<byte[]>`

public class IOStreamEmuUnixFileHandle extends AbstractStreamEmuUnixFileHandle<byte[]>
A simulated file descriptor that proxies a host resource, typically a console/terminal

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final InputStream`
  `input`
  `protected final OutputStream`
  `output`

  ### Fields inherited from class ghidra.pcode.emu.unix.AbstractStreamEmuUnixFileHandle

  `arithmetic, offsetBytes`

  ### Fields inherited from interface ghidra.pcode.emu.unix.EmuUnixFileDescriptor

  `FD_STDERR, FD_STDIN, FD_STDOUT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `IOStreamEmuUnixFileHandle(PcodeMachine<byte[]> machine, CompilerSpec cSpec, InputStream input, OutputStream output)`
  Construct a proxy for a host resource

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Close this descriptor
  `byte[]`
  `read(byte[] buf)`
  Read from the file opened by this handle
  `static IOStreamEmuUnixFileHandle`
  `stderr(PcodeMachine<byte[]> machine, CompilerSpec cSpec)`
  Construct a proxy for the host's standard error output
  `static IOStreamEmuUnixFileHandle`
  `stdin(PcodeMachine<byte[]> machine, CompilerSpec cSpec)`
  Construct a proxy for the host's standard input
  `static IOStreamEmuUnixFileHandle`
  `stdout(PcodeMachine<byte[]> machine, CompilerSpec cSpec)`
  Construct a proxy for the host's standard output
  `byte[]`
  `write(byte[] buf)`
  Read into the file opened by this handle

  ### Methods inherited from class ghidra.pcode.emu.unix.AbstractStreamEmuUnixFileHandle

  `getOffset, seek, stat`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### input

    protected final InputStream input

  - ### output

    protected final OutputStream output

- ## Constructor Details

  - ### IOStreamEmuUnixFileHandle

    public IOStreamEmuUnixFileHandle(PcodeMachine<byte[]> machine, CompilerSpec cSpec, InputStream input, OutputStream output)
    Construct a proxy for a host resource

    WARNING: Think carefully before proxying any host resource to a temperamental target program.

    Parameters:
      `machine` - the machine emulating the hardware
      `cSpec` - the ABI of the target platform
      `input` - the stream representing the input side of the descriptor, if applicable
      `output` - the stream representing the output side of the descriptor, if applicable

- ## Method Details

  - ### stdin

    public static IOStreamEmuUnixFileHandle stdin(PcodeMachine<byte[]> machine, CompilerSpec cSpec)
    Construct a proxy for the host's standard input
    Parameters:
      `machine` - the machine emulating the hardware
      `cSpec` - the ABI of the target platform
    Returns:
      the proxy's handle

  - ### stdout

    public static IOStreamEmuUnixFileHandle stdout(PcodeMachine<byte[]> machine, CompilerSpec cSpec)
    Construct a proxy for the host's standard output
    Parameters:
      `machine` - the machine emulating the hardware
      `cSpec` - the ABI of the target platform
    Returns:
      the proxy's handle

  - ### stderr

    public static IOStreamEmuUnixFileHandle stderr(PcodeMachine<byte[]> machine, CompilerSpec cSpec)
    Construct a proxy for the host's standard error output
    Parameters:
      `machine` - the machine emulating the hardware
      `cSpec` - the ABI of the target platform
    Returns:
      the proxy's handle

  - ### read

    public byte[] read(byte[] buf) throws EmuIOException
    Description copied from interface: `EmuUnixFileDescriptor`
    Read from the file opened by this handle
    Parameters:
      `buf` - the destination buffer
    Returns:
      the number of bytes read
    Throws:
      `EmuIOException` - if an error occurred

  - ### write

    public byte[] write(byte[] buf) throws EmuIOException
    Description copied from interface: `EmuUnixFileDescriptor`
    Read into the file opened by this handle
    Parameters:
      `buf` - the source buffer
    Returns:
      the number of bytes written
    Throws:
      `EmuIOException` - if an error occurred

  - ### close

    public void close()
    Description copied from interface: `EmuUnixFileDescriptor`
    Close this descriptor