Skip to content

Commit cce1654

Browse files
committed
fix(fs): validate directory path in dir() on Windows
1 parent f6395ec commit cce1654

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/mods/fs.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,14 @@ function M.dir(p, opts)
425425
assert_arg(2, opts, "table", true)
426426
opts = normalize_dir_opts("dir", opts)
427427

428+
local mode, err = lfs.attributes(p, "mode")
429+
if not mode then
430+
return nil, err
431+
end
432+
if mode ~= "directory" then
433+
return nil, "Not a directory"
434+
end
435+
428436
local items = {}
429437
local ok, err = collect_dir_items(p, opts, items, false)
430438
if not ok then

0 commit comments

Comments
 (0)