I try to integrate lua to my project (lua 5.2.1)
And i have no problem to compile it.
But my problem is my project use my own system for read/write file from the file system.
So I start to modify lua for replacing each call of fopen / fclose / fread / fwrite …
But the problem is Lua is too much mix if stdio fct ans use some FILE function I don’t have equivalent in my project (and no so easy to reimplement), like :
ungetc
setvbuff
And so on….
My question ^^
Some aleeady try to do that ? And if yes how ?
Does someone now a extension of lua who have this functionality (some c library use callback fct to ask open/close a file) ?
It’s seams strange to me that lua who is really use on multi-platfroms os or even embeded system make a so strong use of std lib, abitualy for really cross platform lib every type and fct from std are typedefed for easy platfroms specifics change.
Thanks for any help you can give me 🙂
You’re not asking about “Lua the language’s” file IO; you’re talking about “Lua the C library’s” file IO. This was not clear from the question.
Lua has provisions for this.
luaL_loadfile, for example, is just syntactic sugar around a function that opens the given file, loads it, closes the file, and then callsluaL_loadstringon it.If you’re in an environment where file IO has to go through different channels, you shouldn’t be trying to make
luaL_loadfilework with the new file IO. You should be writing a new function which loads a file from your filesystem and callsluaL_loadstring.In short: you shouldn’t be using any Lua APIs that require files. Lua’s file-based functions are convenience functions; nothing more. Lua itself already has provisions for this; every file-based API has a non-file-based version that can work just as well. You should not be modifying Lua itself.