I want to save and load levels for my game. The std.stream module doesn't have much examples.

Here is my code:
void saveLevel( string fileName ) {
        auto bfile = new std.stream.File;

        int ver = 1;
        string verStr = "version:";
        with( bfile ) {
                scope( exit )
                        close;
                create( fileName );
                write( verStr ); write( ver ); // version
        }

        int ver2;
        char[] verStr2;
        auto bfile2 = new std.stream.File;
        with( bfile2 ) {
                scope( exit )
                        close;
                create( fileName );
                read( verStr2 ); read( ver2 ); // version
        }
        writeln( verStr, ver );
}

And this is the result:
std.stream.ReadException@std\stream.d(46): Stream is not readable

- Joel

Reply via email to