lua-users home
lua-l archive

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


On 10/27/07, Duck <duck@roaming.ath.cx> wrote:
> >Version 1.3.0 added function lfs.symlinkattributes
> >(works only in non Windows systems).
>
> Pity. This would be so much more generally useful if it were portable to
> Windows. Windows NT and later supports symlinks. (Up to Vista, only
> directories can be soft-linked; such links are called 'junctions' or
> 'mount points'. From Vista on, both files and directories can be
> soft-linked; such links are, imaginatively, known as symbolic links.)
>
> Perhaps a portable "issoftlink()" function for both platforms?

Wouldn't it be enough to return lfs. attributes(filename).mode ==
"link" in this case?

> On Linux/Unix IIRC I assume that you can simply compare the inode from
> stat() and lstat(). On Windows it's a bit fussier and involves checking
> for a file attribute of FILE_ATTRIBUTE_REPARSE_POINT, and then for a
> further attribute of IO_REPARSE_TAG_MOUNT_POINT (for pre-Vista-style
> junctions) or of IO_REPARSE_TAG_SYMLINK (Vista-and-later-style symlinks).
>
> http://msdn2.microsoft.com/en-us/library/aa363940.aspx
>
> Would these two strategies allow issoftlink() to be implemented reliably
> on Windows, Unix, Linux (and presumably whatever cat the current flavour
> of Apple's OS is named after at the moment)?

That I idon't know, but assuming the current form (using
lfs.attributes already work for the unix/linux then adding some
detection for the Windows case should not have any impacts, right?

André