Skip to content

Instantly share code, notes, and snippets.

@perusio
Created February 14, 2012 05:29
Show Gist options
  • Save perusio/1823888 to your computer and use it in GitHub Desktop.
Save perusio/1823888 to your computer and use it in GitHub Desktop.
Test if a file exists using Lua posix
-- Test if a file exists using Lua posix https://github.com/rrthomas/luaposix.
local posix = require('posix')
-- Test if a file exists.
-- @param fname string
-- filename
-- @return boolean
-- true if file exists, false otherwise
--
function file_exists(fname)
return posix.stat(fname).type == 'regular'
end -- file_exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment