Re: Using C's fread/fwrite with File objects

2015-10-22 Thread pineapple via Digitalmars-d-learn
On Thursday, 22 October 2015 at 18:28:50 UTC, Ali Çehreli wrote: If you already have a piece of memory, it is trivial to convert it to a slice in D: auto slice = existing_pointer[0 .. number_of_elements]; http://ddili.org/ders/d.en/pointers.html#ix_pointers.slice%20from%20pointer The opera

Re: Using C's fread/fwrite with File objects

2015-10-22 Thread John Colvin via Digitalmars-d-learn
On Thursday, 22 October 2015 at 18:20:07 UTC, pineapple wrote: I'd like to use fread and fwrite in place of File.rawRead and File.rawWrite which force the creation of an array where I'd rather specify a buffer location and length. D's arrays *are* just buffer locations and lengths with a few

Re: Using C's fread/fwrite with File objects

2015-10-22 Thread Ali Çehreli via Digitalmars-d-learn
On 10/22/2015 11:20 AM, pineapple wrote: > I'd like to use fread and fwrite in place of File.rawRead and > File.rawWrite which force the creation of an array where I'd rather > specify a buffer location and length. Would you not create that buffer? :) If you already have a piece of memory, it is

Re: Using C's fread/fwrite with File objects

2015-10-22 Thread pineapple via Digitalmars-d-learn
Answered my own question: Turns out File.getFP() does exactly what I needed

Using C's fread/fwrite with File objects

2015-10-22 Thread pineapple via Digitalmars-d-learn
I'd like to use fread and fwrite in place of File.rawRead and File.rawWrite which force the creation of an array where I'd rather specify a buffer location and length. I'd like to do this using a File object but the handle for the C stream is a private member and I can't find any way to access