Re: How to detect symlinks?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: How to detect symlinks?
- From: Jeff Pohlmeyer <yetanothergeek@...>
- Date: 2012年4月30日 00:57:29 -0500
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