[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: check if file exists
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Sun, 24 Nov 2002 15:39:14 +0100
Markus Huber wrote:
> > Björn De Meyer wrote:
> > > Markus Huber wrote:
> > > Any ideas how to check the existence of a file?
> > Try opening the file with read only access.
> > If that fails the file does not exist.
> Isn't it possible that the file exists with write access only? Or
> a protected file without read and write access? The file exists but
> opening fails.
Yes, that is possible. However, such are the limitations of
ANSI C. And Lua's standard libraries are based upon pure ANSI C.
So either you integrate poslib for lua into your application,
or you make do with ANSI C. If you really must use the standard
Lua, then maybe the os.execute() function (Lua 5) can help.
With that, you can execute an arbitrary command, such as,
say, the Unix utility "test". Write the result of "test"
to a file or such, and read that back into Lua.
"No one knows true heroes, for they speak not of their greatness." --
Björn De Meyer