lua-users home
lua-l archive

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


>>>>> "Björn" == Björn De Meyer <bjorn.demeyer@pandora.be> writes:

    Björn> Markus Huber wrote:
    Markus>>  Any ideas how to check the existence of a file?  Or better
    Markus>> read the object type e.g.:
    Markus>> 
    Markus>> 0 doesn't exist 1 is a file 2 is a directory 3 is a link (I
    Markus>> don't know the exact name of this type)
    >> [...]

    Björn> Try opening the file with read only access.  If that fails
    Björn> the file does not exist.  The other functionality you would
    Björn> like is beyond the scope of ANSI C, and therefore you will
    Björn> have to extend Lua yourself with these functions.

On POSIX systems you can use the access(2) and stat(2) system calls.

But please notice that Ansi C knows only (at most, ie not in
standalone or embedded implementations) about files (thru <stdio.h>)
and does *not* know about directories.

Perhaps we could wish a Lua interface to major Posix calls, but this
is a big work (and would make lua quite big).

Regards.
-- 

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
alias: basile<at>tunes<dot>org 
8, rue de la Faïencerie, 92340 Bourg La Reine, France