mirror of
https://github.com/lunarmodules/luafilesystem.git
synced 2026-07-22 02:53:06 +00:00
added explicit next and close methods to second return value of lfs.dir (the directory object), for explicit iteration or explicit closing
This commit is contained in:
@@ -110,4 +110,21 @@ for i = 1, 4000 do
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Stressing directory iterator, explicit version
|
||||
count = 0
|
||||
for i = 1, 4000 do
|
||||
local iter, dir = lfs.dir(tmp)
|
||||
local file = dir:next()
|
||||
while file do
|
||||
count = count + 1
|
||||
file = dir:next()
|
||||
end
|
||||
assert(not pcall(dir.next, dir))
|
||||
end
|
||||
|
||||
-- directory explicit close
|
||||
local iter, dir = lfs.dir(tmp)
|
||||
dir:close()
|
||||
assert(not pcall(dir.next, dir))
|
||||
print"Ok!"
|
||||
|
||||
Reference in New Issue
Block a user