ClientUser::OutputBinary( const char *, int )

Output binary data.

Virtual?

Yes

 

Class

ClientUser

 

Arguments

const char *data

a pointer to the first byte of data to output

 

int length

the number of bytes to output

Returns

void

 

Notes

The default implementation of OutputBinary() writes the contents of a binary file to stdout. A call to OutputBinary() is typically the result of running p4 print on a binary file:

p4 print //depot/file.jpg > newfile.jpg

Example

To modify the way in which binary files are output with p4 print, create a subclass of ClientUser with an alternate implementation of OutputBinary().

For example, suppose that you want PDF files to be printed to stdout as plain text. Add the following code (that checks to see if the file is PDF and, if so, calls a hypothetical OutputPDF() function to output PDFs to stdout) to the beginning of your implementation of OutputBinary().

void MyClientUser::OutputBinary( const char *data, int length )
{
    static unsigned char pdfFlag[] = { '%', 'P', 'D', 'F', '-' };
    if ( length >= 5 && memcmp( data, pdfFlag, sizeof( pdfFlag ) ) )
         OutputPDF( data, length );
    else
        ClientUser::OutputBinary( data, length );
}