Implemenation of 'ex' API - portable os and io extension functions
C Lua
Latest commit 6924c51 Feb 18, 2013 @drahosp drahosp Updated travis hook
Permalink
Failed to load latest commit information.
cmake
posix Fix __close method for pipes due to change in Lua 5.1.3 fixing this b… Jun 26, 2009
w32api fix win32 compiler warning - memcpy return unknown size Mar 28, 2011
.travis.yml
CMakeLists.txt New CMake macros Aug 1, 2012
COPYRIGHT
Changelog
INSTALL
JUST
Makefile
README Correct email address. Jun 26, 2009
TODO
conf.in Correct email address. Jun 26, 2009
dist.info
ex.def
test.lua add basic tests Apr 27, 2012

README

"ex" API implementation
http://lua-users.org/wiki/ExtensionProposal
Copyright 2007 Mark Edgar < medgar at gmail com >

-- Environment
os.getenv(name) -- get environment variable
os.setenv(name, value) -- set/unset environment variable
os.environ() -- returns a copy of the environment

-- File system
cwd = os.currentdir()
os.chdir(pathname)
os.mkdir(pathname)
os.remove(pathname)

for entry in os.dir(pathname) do ; end
entry = os.dirent(pathname)
--[[
  entry is a table, containing at least the following keys:
  name: the filename
  type: "file" or "directory" or another implementation-defined string
  size: the file size in bytes
--]]

-- Locking and pipes
file = io.open("filename", "w")
file:lock(mode, start, length) -- mode is "r" or "w", start and length are optional
file:unlock(start, length) -- start and length are optional
in, out = io.pipe()

-- Process control
os.sleep(seconds) -- sleep for (floating-point) seconds
os.sleep(interval, unit) -- sleep for interval/unit seconds
pid = os.spawn(filename, {args={}, env={}, stdin=file, stdout=file, stderr=file})
exitcode = pid:wait(pid)