Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2026.1

# FileSys::Read( const char *, int, Error * )

Attempt to read `len` bytes of data from the object referenced by the file handle (returned by the `Open()` method) to the buffer pointed to by `buf`. Upon successful completion, `Read()` returns the number of bytes actually read and placed in the buffer.

Virtual? | Yes |
Class | `FileSys` |
Arguments | `const char *buf` | pointer to buffer into which to read data
| `int len` | length of data to read
| `Error *error` | returned error status
Returns | `int` | number of bytes actually read

## Notes

The default implementation of `Read()` is called every time there is a need to read data from the file referenced by the `Open()` call.

Your implementation must correctly report any system errors that might occur during I/O.

## Example

To use `Read()` to read a line from a log file:

Copy

    char line[80];
    m.Set( msg );
    FileSys *f = FileSys::Create( FST_ATEXT );
    Error e;

    f-&gt;Set( "C:\\logfile.txt" );
    f-&gt;Open( FOM_READ, &amp;e );
    f-&gt;Read( line, 80, &amp;e );
    f-&gt;Close( &amp;e );

To reimplement `Read()` to report errors with `Error::Sys()`, provide debugging output, and use the `FileSysDemo` member “fd” to hold the file handle returned from the `read()` system call:

Copy

    int FileSysDemo::Read( char *buf, int len, Error *e )
    {
        int bytes;

        if ( ( bytes = read( fd, buf, len ) ) &lt; 0 )
            e-&gt;Sys( "read", Name() );

        if ( DEBUG )
        {
            printf( "debug (Read): %d bytes\n", bytes );
        }

        return( bytes );
    }

Your search for returned results