lua-users home
lua-l archive

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




On 2/15/2012 3:19 PM, Rob Kendrick wrote:
On Wed, Feb 15, 2012 at 11:50:47AM +0200, steve donovan wrote:
Hi all,

Inspired by Jay's challenge to keep it simple&  stupid, I've come up
with thirty-odd functions that cover a lot of the general boilerplate
code we end up writing. 'Microlight' because it's the trimmed-down
younger brother of Penlight, about 500 lines in total, of which 160
are doc comments.

https://gist.github.com/1834789

And the extracted docs are at

http://stevedonovan.github.com/microlight/

splitpath (P)
	split a file path. if there's no directory part, the first value will be
	the empty string
	Parameters:
		P: A file path

This can't possibly be portable, and is already covered by
LuaFileSystem, no?  Beyond the usual UNIX, Windows and MacOS, there are
esoteric OSes which Lua is popular on such as RISC OS that have truely
baroque syntax.  The BNF for RISC OS's path syntax is possibly longer
than that of Lua's.

While this is true, it probably covers the major OS-es there. If you are on more obscure OS, you would be already more aware.

For sure LuaFileSystem does not cover how to handle windows filename with space at the end :)

Even using Windows functions (GetFullPathName) would fail you in this very rare case.

(For example if you want to delete such Windows file with spaces to the end, then you have to turn all / to \, remove duplicate ones, and prepend \\?\ to the name -e .g. "\\?\C:\somefile.txt " - without the quotes).

Hardly anyone could handle this special case, on the most desktop popular system.

And please let's not go the Common Lisp way, supporting even versioning (not that Windows does not have it - through streams, and I use it actively, but still).