How to check if a file is executable in Lua? -
how can check in lua if string path executable file? seems neither standard library nor, surprisingly, luafilesystem provides way this.
luafilesystem has lfs.attributes() function returns table. that, rather perversely, has key named "mode" contains string describing "type" of node (file, directory, socket, etc).
although it's not listed in manual at: http://keplerproject.github.io/luafilesystem/manual.html ... seems canonical reference module ... there 'permissions' key in table. think parse "x" characters.
i discovered with:
#!lua local lfs = require 'lfs' attr = lfs.attributes('./some_file') name, value in pairs(attr) print (name,value) end
Comments
Post a Comment