diff options
Diffstat (limited to 'core/lfs_ext.lua')
-rw-r--r-- | core/lfs_ext.lua | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/core/lfs_ext.lua b/core/lfs_ext.lua index 36dfeffc..6e4f0ccf 100644 --- a/core/lfs_ext.lua +++ b/core/lfs_ext.lua @@ -40,20 +40,18 @@ local function exclude(file, filter) end --- --- Iterates over all files and sub-directories in the UTF-8-encoded directory --- *utf8_dir*, calling function *f* on each file found. +-- Iterates over all files and sub-directories in directory *dir*, calling +-- function *f* on each file found. -- Files *f* is called on do not match any pattern in string or table *filter*, -- and, unless *exclude_FILTER* is `true`, `FILTER` as well. A filter table -- contains Lua patterns that match filenames to exclude, with patterns matching -- folders to exclude listed in a `folders` sub-table. Patterns starting with -- '!' exclude files and folders that do not match the pattern that follows. Use -- a table of raw file extensions assigned to an `extensions` key for fast --- filtering by extension. All strings must be encoded in `_G._CHARSET`, not --- UTF-8. --- @param utf8_dir A UTF-8-encoded directory path to iterate over. --- @param f Function to call with each full file path found. File paths are --- **not** encoded in UTF-8, but in `_G._CHARSET`. If *f* returns `false` --- explicitly, iteration ceases. +-- filtering by extension. +-- @param dir The directory path to iterate over. +-- @param f Function to call with each full file path found. If *f* returns +-- `false` explicitly, iteration ceases. -- @param filter Optional filter for files and folders to exclude. -- @param exclude_FILTER Optional flag indicating whether or not to exclude the -- default filter `FILTER` in the search. If `false`, adds `FILTER` to @@ -64,7 +62,7 @@ end -- not be set otherwise. -- @see FILTER -- @name dir_foreach -function lfs.dir_foreach(utf8_dir, f, filter, exclude_FILTER, recursing) +function lfs.dir_foreach(dir, f, filter, exclude_FILTER, recursing) if not recursing then -- Convert filter to a table from nil or string arguments. if not filter then filter = {} end @@ -81,7 +79,6 @@ function lfs.dir_foreach(utf8_dir, f, filter, exclude_FILTER, recursing) local ext = filter.extensions if ext then for i = 1, #ext do ext[ext[i]] = true end end end - local dir = utf8_dir:iconv(_CHARSET, 'UTF-8') local lfs_attributes = lfs.attributes for file in lfs.dir(dir) do if not file:find('^%.%.?$') then -- ignore . and .. |