lua-users home
lua-l archive

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



LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.

[...]

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?

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)?