[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How do I test for the existens of a file
- From: ketmar <ketmar@...>
- Date: Sun, 26 Oct 2008 02:11:44 +0300
On Sat, 25 Oct 2008 16:06:05 -0700 (PDT)
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
use lfs module (search at LuaForge), or write this:
local fl = io.open("file.to.test");
if fl then
fl:close();
<file exists; do not forget to close it first. or read data if that's
what you need>
else
print("no file. so sad.");
end;