Stop returning dotted directory names in os.matchdirs()
This commit is contained in:
parent
f4e55da621
commit
cb0aba47f3
@ -220,7 +220,6 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
function os.match(mask, matchFiles)
|
function os.match(mask, matchFiles)
|
||||||
|
|
||||||
-- Strip any extraneous weirdness from the mask to ensure a good
|
-- Strip any extraneous weirdness from the mask to ensure a good
|
||||||
-- match against the paths returned by the OS. I don't know if I've
|
-- match against the paths returned by the OS. I don't know if I've
|
||||||
-- caught all the possibilities here yet; will add more as I go.
|
-- caught all the possibilities here yet; will add more as I go.
|
||||||
@ -256,12 +255,15 @@
|
|||||||
while os.matchnext(m) do
|
while os.matchnext(m) do
|
||||||
local isfile = os.matchisfile(m)
|
local isfile = os.matchisfile(m)
|
||||||
if (matchFiles and isfile) or (not matchFiles and not isfile) then
|
if (matchFiles and isfile) or (not matchFiles and not isfile) then
|
||||||
local fname = path.join(basedir, os.matchname(m))
|
local fname = os.matchname(m)
|
||||||
|
if isfile or not fname:startswith(".") then
|
||||||
|
fname = path.join(basedir, fname)
|
||||||
if fname:match(mask) == fname then
|
if fname:match(mask) == fname then
|
||||||
table.insert(result, fname)
|
table.insert(result, fname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
os.matchdone(m)
|
os.matchdone(m)
|
||||||
|
|
||||||
-- check subdirectories
|
-- check subdirectories
|
||||||
|
@ -40,6 +40,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- os.matchdirs() tests
|
||||||
|
--
|
||||||
|
|
||||||
|
function suite.matchdirs_skipsDottedDirs()
|
||||||
|
local result = os.matchdirs("*")
|
||||||
|
test.isfalse(table.contains(result, ".."))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- os.matchfiles() tests
|
-- os.matchfiles() tests
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user