lua-users home
lua-l archive

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


On Sun, Apr 29, 2012 at 23:57, Jeff Pohlmeyer <yetanothergeek@gmail.com> wrote:
> On Sun, Apr 29, 2012 at 11:35 PM, Rena <hyperhacker@gmail.com> wrote:
>
>> How with Lua/LFS can I tell if a file is a symlink? LFS has
>> symlinkattributes, but that only gives information about the link
>> itself, with no apparent way to tell if the file is actually a link or
>> not. (Given a non-symlink, it behaves identically to lfs.attributes.)
>
>
> I think this might work:
>
> function IsSymLink(filename)
>  local a = lfs.attributes(filename)
>  local s = lfs.symlinkattributes(filename)
>  return a and s and ( a.dev ~= s.dev or a.ino ~= s.ino )
> end
>
>  - Jeff
>

Thanks, that appears to work. Still is there a way to open the link
itself instead of the file it points to?

-- 
Sent from my Game Boy.