darn I have to make boost work in my IDE. I'm missing out so many cool features, starting with regular expressions :(

If you want, you could rewrite my function to just call new[] and delete[] directly instead of using a scoped_array.

08-12-2007

MacNilly

Complete rewrite

I did a complete re-write. I fixed some of the things that were mentioned.
One question though, I can't figure out how to test if my "backup/restore" plan will work. I already tried deleting the file in the middle of an encryption and the original file disappears. Any ideas how to generate some file errors?

> tmpbuf[j] = buf[j];
If this is meant to be holding the whole file, in case of failure, then it's wrong.
It just keeps using the BUFSIZ start of the memory.
Holding very large files in memory will just thrash the virtual memory.

> if (!fp)
Except the result is in *fp

> return (int)*fp;
Ugly, use
return *fp != NULL;

> fwrite(tmpbuf, 1, getsize(fp), fp);
Maybe call getsize() just the once, given that it messes with the file pointer.
Calling getsize() in the middle of file processing would be a disaster.

> Any ideas how to generate some file errors?
Which OS are you on?

08-13-2007

MacNilly

Quote:

Originally Posted by Salem

Which OS are you on?

Linux. Would probably help to fill out my profile, guess I'll do that now.