std.file.read

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Aug 2 01:23:17 PDT 2010


On 02.08.2010 5:23, bearophile wrote:
> Can you tell me why std.file.read() returns a void[] instead of something like a ubyte[]?
>
>    
Well, it  magically converts to whatever array type you have.  So this 
works:
ubyte[] data = read("trash.txt");

It's interesting fact deserving further investigation. It seems that 
void[] arrays are converted implicitly, this also works:
void[] tr = malloc(20)[0..20];
data = tr;
> (Performing a cast(ubyte[]) in SafeD can be a problem. I presume in SafeD I have to use other safer functions to load binary data, like slurp() or something similar.)
>
> Bye,
> bearophile
>    
-- 

Dmitry Olshansky



More information about the Digitalmars-d-learn mailing list