lua-users home
lua-l archive

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


Perhaps a portable "issoftlink()" function for
both platforms?

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

Errrrr, isn't that where we started? The mode field is a single, specific value, not a list (table). So the things it can tell you about any file system object are limited. In particular, it can't tell you that a directory is also a soft link, which makes it impossible reliably to prevent cycles when walking a directory tree.

lfs.symlinkattributes() now gives a way around this, but on Unix only, which rather squashes the concept of portability mentioned in the lfs docs.

After all, love it or hate it, there are very many more Windows computers out there than Linux/Unix computers. (And several hundred thousand -- shall we say one million? -- of the Linux computers in the world are due to Google.)

Incidentally, is there a way under Windows (pre-Vista) to differentiate between a mount point (at which a subdirectory redirects you onto another volume) and a "simple" junction (where a subdirectory redirects you to another part of the same directory tree)?

From what I can see, MS seem to use the term mount point to imply any
directory which is a soft link, presumably under the assumption that the primary use for this feature is to graft disk volumes together and thus to overcome/avoid the need for (and limit in the total number of) drive letters.

I am thinking that

  issoftink()

and

  ismountpoint()

functions would be nice to have...but on Windows I'm not sure how to find if a directory actually is an _active_ mount point (has another volume mounted in it) instead of simply finding out that, pre-Vista, it's a junction.