lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


The Doctor wrote:
I'm new enough to this, that I might be missing something, but this can be done in the main code of Lua as supplied. I'm using Windows. I was warned to be careful about btye order but this is working and not a problem for me.

These are the two functions I've worked out for handling save amd load of binary files:

function DataLoad(F) F=assert(io.open(F,"rb")) local D=F:read("*a") F:close() return D end function DataSave(F,D) F=assert(io.open(F,"wb")) F:write(D) F:close() end
If it's this easy, why add a special library to what's already there?

For a very very minimal footprint, using the FILE* operations in the libc means you have to use the libc. Using direct system calls means you don't, so you can use a smaller runtime library. Under UNIX for example, some small bindings to open/read/write/close will be many times smaller than bindings to fopen/fscanf/fprintf/fclose and the required support code, for example.

--
Rob Kendrick, Pepperfish Ltd.         +44 (0)845 226 4146  www.pepperfish.net
PGP signed or encrypted mail welcome                         Key ID: 3651D17A