lua-users home
lua-l archive

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


It was thus said that the Great Jeff Pohlmeyer once stated:
> On Jan 22, 2020 5:47 PM Sean Conner wrote:
> >   Okay, second take.  I've looked at LuaFileSystem, LuaPosix, PenLight and
> > my own org.conman.fsys modules and I've come up with a set of minimal
> > directory functions.
> 
> Looks like a good start. A few questions...
> 
> Why call it "setwd" instead of the more conventional "chdir" ?

  To make it consistent with getwd().

> If info() is called on a symlink, does it return info about the link
> itself, or the file the link points to?

  What's this "symlink" you speak of?

  Okay, I know what they are, but this is meant to be a minimum support. But
to answer your question, the file it points to (POSIX supports lstat() to
return the information about the link).  I know Windows has *some* hacked
version of symlinks, but I'm not sure of the extend (MS-DOS for instance,
doesn't have symlinks, and I've seen Lua ompiled for MS-DOS).

> (Maybe that could be a separate function or perhaps an optional
> "aslink" boolean parameter.)

  What happens when a system doesn't support it?  POSIX has hardlinks (which
are different from symlinks) but Windows doesn't have that support.  What
then?

> If timestamp() is called on a nonexistent file, will it attempt create
> the file? (a la "touch")

  No.  The underlying POSIX call, utime(), does not create the file.

> It would also be nice to have a small subset of permission functions,
> maybe just whether a file can be read, written, or created.

  If you can't read a file, you can't read a file.  I know there are times
when checking first is preferred, but just the act of trying to open a file
will tell you what you need to know (and there's a race between time of
check and time of use (TOCTOU).

  -spc