Interface Cio

interface Cio {
    beginCapture(fullPath: string, append?: boolean): void;
    endCapture(): void;
    getLastStdErr(): string;
    getLastStdOut(): string;
}

Methods

  • Start capturing stdout and stderr from the target program (e.g. printf) to specified file.

    Parameters

    • fullPath: string

      The full path to the file to which stdout and stderr are to be captured

    • Optionalappend: boolean

      Whether to append to the file instead of overwriting it (default: false)

    Returns void

    Will create the file if it does not exist. Will throw if the file cannot be opened for writing.

    // overwrite file if it already exists
    session.cio.beginCapture("C:/capturedOutput.txt");
    session.cio.beginCapture("C:/capturedOutput.txt", false);

    // append to file if it already exists
    session.cio.beginCapture("C:/capturedOutput.txt", true);
  • Stop capturing to the file

    Returns void

    Does nothing if no capture is in progress

    session.cio.endCapture();
    
  • Get the latest buffered standard error text as a string

    Returns string

    The latest buffered standard error

    const lastStdErr = session.cio.getLastStdErr();
    console.log(`Last standard error: ${lastStdErr}`);
  • Returns the latest buffered standard output text as a string

    Returns string

    The latest buffered standard output

    const lastStdOut = session.cio.getLastStdOut();
    console.log(`Last standard output: ${lastStdOut}`);