Skip to main content

Crate lua_rs_lfs

Crate lua_rs_lfs 

Source
Expand description

Rust-native port of the LuaFileSystem (lfs) module — Phase G-1.

Provides the lfs functions LuaRocks actually uses:

functionstd::fs / std::env equivalent
lfs.attributes(path [, req])std::fs::metadata(path)
lfs.dir(path)std::fs::read_dir(path)
lfs.mkdir(path)std::fs::create_dir(path)
lfs.rmdir(path)std::fs::remove_dir(path)
lfs.chdir(path)std::env::set_current_dir(path)
lfs.currentdir()std::env::current_dir()
lfs.touch(path [,a [,m]])filetime::set_file_times
lfs.link(old, new [, sym])std::fs::hard_link / symlink
lfs.lock_dir(path)atomic lockfile.lfs creation

Out of scope (LuaRocks does not exercise these): lfs.lock, lfs.unlock, lfs.symlinkattributes, lfs.setmode.

Registration: the entry point luaopen_lfs builds and returns the lfs table. lua-cli installs that function in package.preload.lfs after open_libs and before user code runs, so require('lfs') resolves via the preload searcher and the rest of the lfs API ends up where stock lfs users expect to find it.

Functions§

luaopen_lfs
Module entry point. Mirrors the stock lfs C signature int luaopen_lfs(lua_State *L) but at the Rust-native ABI used inside this workspace: builds the lfs table, populates it with the 8 functions above, and returns 1 to signal “one return value on the stack”.