diff options
author | Hans Hagen <pragma@wxs.nl> | 2011-02-09 16:42:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2011-02-09 16:42:00 +0100 |
commit | 275284936a065306f96342005d322e0ac9f18db6 (patch) | |
tree | b96e7b345853723847d549cb1f0e0cd3339ea40a /scripts/context/stubs/mswin/mtxrun.lua | |
parent | f6bc304822e6ae57bd183ea23a8f885467165d9d (diff) | |
download | context-275284936a065306f96342005d322e0ac9f18db6.tar.gz |
beta 2011.02.09 16:42
Diffstat (limited to 'scripts/context/stubs/mswin/mtxrun.lua')
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index fed0e13f4..187b26e06 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -2927,21 +2927,32 @@ end -- optimizing for no find (*) does not save time +local lfsisdir = isdir + +local function isdir(path) + path = gsub(path,"[/\\]+$","") + return lfsisdir(path) +end + +lfs.isdir = isdir + local function globpattern(path,patt,recurse,action) if path == "/" then path = path .. "." elseif not find(path,"/$") then path = path .. '/' end - for name in walkdir(path) do - local full = path .. name - local mode = attributes(full,'mode') - if mode == 'file' then - if find(full,patt) then - action(full) - end - elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then - globpattern(full,patt,recurse,action) + if isdir(path) then -- lfs.isdir does not like trailing / + for name in walkdir(path) do -- lfs.dir accepts trailing / + local full = path .. name + local mode = attributes(full,'mode') + if mode == 'file' then + if find(full,patt) then + action(full) + end + elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then + globpattern(full,patt,recurse,action) + end end end end |