diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2016-04-02 23:35:15 -0400 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2016-04-02 23:35:15 -0400 |
commit | 0c4915da62a96bf6db20377ce11fa887b6271ad9 (patch) | |
tree | 4bc7d4b0722bce49aebf341841f3ab4fa8ad1dfd /core/lfs_ext.lua | |
parent | f6705b546d2f037302f2d2d95bae507e78b29d59 (diff) |
Code cleanup.
Do not use `ipairs()` and use more consistent variable names among other things.
Diffstat (limited to 'core/lfs_ext.lua')
-rw-r--r-- | core/lfs_ext.lua | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/lfs_ext.lua b/core/lfs_ext.lua index 43fe6ebc..b2b89a88 100644 --- a/core/lfs_ext.lua +++ b/core/lfs_ext.lua @@ -103,17 +103,17 @@ function lfs.dir_foreach(dir, f, filter, exclude_FILTER, n, include_dirs, level) if ext then for i = 1, #ext do ext[ext[i]] = true end end end local dir_sep, lfs_attributes = not WIN32 and '/' or '\\', lfs.attributes - for file in lfs.dir(dir) do - if not file:find('^%.%.?$') then -- ignore . and .. - file = dir..(dir ~= '/' and dir_sep or '')..file - local type = lfs_attributes(file, 'mode') - if type == 'directory' and not exclude(file, filter.folders) then - if include_dirs and f(file..dir_sep) == false then return end + for basename in lfs.dir(dir) do + if not basename:find('^%.%.?$') then -- ignore . and .. + local filename = dir..(dir ~= '/' and dir_sep or '')..basename + local mode = lfs_attributes(filename, 'mode') + if mode == 'directory' and not exclude(filename, filter.folders) then + if include_dirs and f(filename..dir_sep) == false then return end if not n or level < n then - lfs.dir_foreach(file, f, filter, nil, n, include_dirs, level + 1) + lfs.dir_foreach(filename, f, filter, nil, n, include_dirs, level + 1) end - elseif type == 'file' and not exclude(file, filter) then - if f(file) == false then return end + elseif mode == 'file' and not exclude(filename, filter) then + if f(filename) == false then return end end end end |