If I have this code
local f = io.open("../web/", "r")
print(io.type(f))
-- output: file
how can I know if f points to a directory?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Lua’s default libraries don’t have a way to determine this.
However, you could use the third-party LuaFileSystem library to gain access to more advanced file-system interactions; it’s cross-platform as well.
LuaFileSystem provides lfs.attributes which you can use to query the file mode: