Closed RiskoZoSlovenska closed 2 years ago
While I see the reasoning in the function. dirname
, basename
and extension
are all very standard in things that manipulate paths. The other issue is that there are many cases where you just need dirname
, or just need extension
, so I'm not sure we should do the extra work when its unnecessary
What will basename
return? Just the root of the filename or the extension as well?
basename
should return the name of the file (everything after the last path separator).
For example basename('/path/to/fs.lua')
should return fs.lua
Ah. I was hoping for a more convenient way to split the root and extension of a filename, something like Python's os.path.splitext
.
If not, Luvit 2.x's path
's basename
accepts an expected_ext
parameter which chops of the extension, any chance that could make it into 3.x too?
If not, Luvit 2.x's
path
'sbasename
accepts anexpected_ext
parameter which chops of the extension, any chance that could make it into 3.x too?
Yes, I missed this but it should exist
Adds
nameSplit()
(if you have a better name, please do suggest), an alternate todirname()
,basename()
andextension()
that returns all of those at once. For example,/folder1/folder2/myFile.lua
would be split into/folder1/folder2/
,myFile
and.lua
.Because in most contexts, you'll need at least two of those.