diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2014-01-29 16:05:48 +0100 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2014-01-29 16:05:48 +0100 |
commit | e4a140c7f0558f50f1134f851c02571c38920e73 (patch) | |
tree | 57f893bcc0d91fe85d38b150b029431b194ad127 /epan/wslua/template-init.lua | |
parent | 447c96304e21c48de0f0f16f1f128e500871155b (diff) |
Lua: Added a utility function file_exists().
This function can be used to check for files before calling dofile(),
which will fail for non-existing files.
Change-Id: Iae7b7ef6d8eb6e0e18f98fee7c740d2a5705eef3
Diffstat (limited to 'epan/wslua/template-init.lua')
-rw-r--r-- | epan/wslua/template-init.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/epan/wslua/template-init.lua b/epan/wslua/template-init.lua index e6ec4ae9ae..74380263d9 100644 --- a/epan/wslua/template-init.lua +++ b/epan/wslua/template-init.lua @@ -64,6 +64,11 @@ function typeof(obj) return mt and mt.__typeof or type(obj) end +function file_exists(name) + local f = io.open(name,"r") + if f ~= nil then io.close(f) return true else return false end +end + -- %WTAP_ENCAPS% -- %WTAP_FILETYPES% |