Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Implemenation of 'ex' API - portable os and io extension functions

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 cmake Updated lua macros August 20, 2012
Octocat-spinner-32 posix
Octocat-spinner-32 w32api
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 CMakeLists.txt
Octocat-spinner-32 COPYRIGHT
Octocat-spinner-32 Changelog
Octocat-spinner-32 INSTALL
Octocat-spinner-32 JUST
Octocat-spinner-32 Makefile
Octocat-spinner-32 README
Octocat-spinner-32 TODO
Octocat-spinner-32 conf.in
Octocat-spinner-32 dist.info
Octocat-spinner-32 ex.def
Octocat-spinner-32 test.lua
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)
Something went wrong with that request. Please try again.