[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] LuaFileSystem 1.7.0
- From: Sean Conner <sean@...>
- Date: Sat, 16 Sep 2017 17:16:18 -0400
It was thus said that the Great Russell Haley once stated:
> Sorry for the top post. LuaRocks is awesome and Lfs suites my needs so it
> makes little difference but it leaves me with questions.
>
> Could someone please *name* a filesystem that they use Lua on that is
> *not* windows or posix compliant?
I can name several---VMS, AmigaOS, MS-DOS 1.0, CP/M. But ones that are
still in use? I don't know. I want to say that iOS and Android file access
is different, but I don't program those (I just hear the complaints at
work). But in general, you are right, POSIX and Windows file systems cover
probably 99.44% of all computer use today.
> Also, I have trouble thinking that filesystem access can't be generalized
> enough to make it extensible. Please, educate me otherwise.
There are semantic differences between the two that would make this ...
interesting. Just iterating over files in a directory. Windows (which is
based off MS-DOS---I have no Windows development experience so I'm falling
back on my MS-DOS arcana here so if the details have changed, forgive me)
has FindFirst() and FindNext(). They work on the current working directory
and it takes a pattern to look for---"*.c" or "foo.*" for example).
POSIX has opendir() and readdir(). It will work for any directory, but it
takes no pattern---it just returns all the files in a directory in an
unspecified order. POSIX also has a function to return all files matching a
pattern ("*.c" or "foo.*" for example) but I've found it has ... quirks
(namely, if *no* files match, it returns the original pattern!).
The other major difference is the patterns themselves. Yes, there are
some patterns that cross ("*.c" or "foo.*") but the pattern for "all files"
is different ("*" for POSIX, "*.*" for Windows). Also, under Windows, the
matching is case-insesitive ("foo.*" will match "FOO.ASM" and "foo.o") while
they aren't for POSIX (but they *might* for Mac OS-X---that's a weird
system). So there's that to watch out for.
Then there's the path separator ("\" for Windows, "/" for POSIX, although
Windows *does* support "/" for the separator as well).
Okay, for a simple job of listing files in a directory, we have:
Windows:
directory needs to be the current working directory
pattern matches case-insensitive
people will use '\' out of habit
OH! Also, Windows returns metainformation about each file
POSIX:
can do any directory
pattern matches case-sensative (maybe except for OS-X)
people will use '/' because that's the only path separator
OH! POSIX only returns the name, no metainformation
And that metainformation? Again, some differences between the two.
Your job, should you choose to accept it, is to figure out the semantics
of a Lua directory iterator.
-spc