mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
37 lines
1.4 KiB
Plaintext
37 lines
1.4 KiB
Plaintext
(NOTE: view this file with a monospaced font)
|
|
|
|
The ROM file system
|
|
================================================================================
|
|
|
|
This is a small, read-only file system built inside eLua. It is integrated with
|
|
Newlib, so you can use standard POSIX calls (fopen/fread/fwrite...) to access
|
|
it. It is also accessible directly from Lua. The files in the file system are
|
|
part of the eLua binary image, thus they can't be modified after the image is
|
|
built. For the seame reason, you can't add/delete files after the image is built.
|
|
To use this file system:
|
|
|
|
- copy all the files you need to the romfs/ directory.
|
|
- Build eLua (docs/building.txt). As part of the build process, "mkfs.py" will
|
|
be called, which will read the contents of the "romfs/" directory and will
|
|
output a file that contains a binary description of the file system.
|
|
- burn your image to the target
|
|
- from your code, whenever you want to access a file, prefix its name with
|
|
"/rom/". For example, if you want to open the "a.txt" file, you should call
|
|
fopen like this:
|
|
|
|
f = fopen( "/rom/a.txt", "rb" )
|
|
|
|
If you want to execute one file from the ROM file system with Lua, simply do
|
|
this from the shell:
|
|
|
|
eLua# lua /rom/bisect.lua
|
|
|
|
Or directly from Lua:
|
|
|
|
> dofile "/rom/bisect.lua"
|
|
|
|
The maximum file name of a ROMFS file is 14 characters, including the dot
|
|
between the file name and its extension. Make sure that the file names from
|
|
romfs/ follow this rule.
|
|
|