www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Reading XDR data from a file

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?

Nov 24 2018