lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Oct 24, 2008 at 2:20 PM, TheLonelyStar <nabble2@lonely-star.org> wrote:
> I want to test if a specific file exist, and do something if yes. Like
>
> if <file exist> then
>  <do something>
> else
>  <do something else>
> end
>
> How do I do that?

I use

function file_exists(file_name)
	local file = io.open(file_name)
	if file then
		file:close()
	end
	return file ~= nil
end


Robby