Skip to content

Instantly share code, notes, and snippets.

@perusio
Created February 14, 2012 05:36
Show Gist options
  • Save perusio/1823926 to your computer and use it in GitHub Desktop.
Save perusio/1823926 to your computer and use it in GitHub Desktop.
Check if a file exists using nixio.
-- Playing with the nixio.fs library.
local nixiofs = require('nixio.fs')
-- Test if a file exists.
-- @param fname string
-- filename
-- @return boolean
-- true if file exists, false otherwise
--
function file_exists(fname)
return nixiofs.stat(fname, 'type') == 'reg'
end -- file exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment