Reading XDR data from a file

Chris Bare chris at bareflix.com
Sat Nov 24 22:43:06 UTC 2018


I have a file in xdr format and I'm trying to use the xdr module 
from dub.
After a lot of failures, I got this to work:

     ubyte[] b2 = cast (ubyte[]) read(fname);
     string n = cast (string) b2.get!string();
     tracef("<%s>", n);

I feel like there should be a way for the xdr get to read 
directly from the file rather than reading it all into a buffer 
first, but no combination of File f = File(fname, "r"); and get  
that I tried would compile.

Also is using cast like this good practice?

--
Chris


More information about the Digitalmars-d-learn mailing list