So far I've been using a simple function I devised that makes use of Open, Read and Close to read a file into a buffer; no stdlib functions are allowed for me, only these sys calls. No problems here.

The project I'm working on however -an implementation of MD5- requires me to read files that may very well exceed the capacity of system RAM.

I thought of working with chunks of 512-1024MB at a time, but splitting the work like this would require me to rewrite my algorithm, at least in part.

Besides if I do, I would have to do some work at the end of the file before I process it anyway -pad it and append some bytes to it- so I would still need to read the whole thing at least once to get the file size with Read, then read again to store the last chunk, pad it and do the other necessary work on the last chunk, then read again from the beginning x-chunks at a time and process the message to get the digest and finally process the last chunk which I stored at the start.

I was wondering if you guys have real life recommendations. Is splitting the workload really the best approach?

Thanks.