diff options
author | Karl Berry <karl@freefriends.org> | 2021-08-28 20:36:53 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-08-28 20:36:53 +0000 |
commit | 36898810305246554a1e0e8a046879cb7c9e6db3 (patch) | |
tree | 7ca67e99234c74c5b48eea2cb29813b5b374e3bf /Master/texmf-dist/scripts/l3build/l3build-file-functions.lua | |
parent | a89cabb9a47555bb218f126342a0a986236b2a02 (diff) |
l3build (28aug21)
git-svn-id: svn://tug.org/texlive/trunk@60344 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/l3build/l3build-file-functions.lua')
-rw-r--r-- | Master/texmf-dist/scripts/l3build/l3build-file-functions.lua | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua b/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua index 6ca1cc60111..53364bd3010 100644 --- a/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua +++ b/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua @@ -211,6 +211,20 @@ function cleandir(dir) return rm(dir, "**") end +function direxists(dir) + return attributes(dir, "mode") == "directory" +end + +function fileexists(file) + local f = open(file, "r") + if f ~= nil then + f:close() + return true + else + return false -- also file exits and is not readable + end +end + -- Copy files 'quietly' function cp(glob, source, dest) local errorlevel @@ -218,7 +232,7 @@ function cp(glob, source, dest) -- p_src is a path relative to `source` whereas -- p_cwd is the counterpart relative to the current working directory if os_type == "windows" then - if attributes(p.cwd, "mode") == "directory" then + if direxists(p.cwd) then errorlevel = execute( 'xcopy /y /e /i "' .. unix_to_win(p.cwd) .. '" "' .. unix_to_win(dest .. '/' .. p.src) .. '" > nul' @@ -241,31 +255,6 @@ function cp(glob, source, dest) return 0 end --- OS-dependent test for a directory -function direxists(dir) - local errorlevel - if os_type == "windows" then - errorlevel = - execute("if not exist \"" .. unix_to_win(dir) .. "\" exit 1") - else - errorlevel = execute("[ -d '" .. dir .. "' ]") - end - if errorlevel ~= 0 then - return false - end - return true -end - -function fileexists(file) - local f = open(file, "r") - if f ~= nil then - f:close() - return true - else - return false -- also file exits and is not readable - end -end - -- Generate a table containing all file names of the given glob or all files -- if absent function filelist(path, glob) @@ -309,16 +298,13 @@ function tree(src_path, glob) local function always_true() return true end - local function is_dir(file) - return attributes(file, "mode") == "directory" - end ---@type table<integer,tree_entry_t> local result = { { src = ".", cwd = src_path, } } for glob_part, sep in glob:gmatch("([^/]+)(/?)/*") do - local accept = sep == "/" and is_dir or always_true + local accept = sep == "/" and direxists or always_true ---Feeds the given table according to `glob_part` ---@param p tree_entry_t path counterpart relative to the current working directory ---@param table table |