public uint8[] readContentsOfFile( string filename ) throws GLib.FileError
{
    Posix.Stat structstat;
    var ok = Posix.stat( filename, out structstat );
    if ( ok == -1 )
    {
        throw new GLib.FileError.FAILED( Posix.strerror(Posix.errno) );
    }

    var fd = Posix.open( filename, Posix.O_RDONLY );
    if ( fd == -1 )
    {
        throw new GLib.FileError.FAILED( Posix.strerror(Posix.errno) );
    }

    var buf = new uint8[structstat.st_size];
    var bread = Posix.read( fd, buf, structstat.st_size );
    if ( bread != structstat.st_size )
    {
        Posix.close( fd );
        throw new GLib.FileError.FAILED( @"Short read; got only $bread of $(structstat.st_size)" );
    }

    Posix.close( fd );
    return buf;
}

void main()
{
}

