| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/laragon4/bin/cmder/vendor/clink-completions/modules/ |
Upload File : |
exports = {}
local w = require('tables').wrap
exports.list_files = function (base_path, mask, recursive, reverse_separator)
local mask = mask or '/*'
local entries = w(clink.find_files(base_path..mask))
:filter(function(entry)
return exports.is_real_dir(entry)
end)
local files = entries:filter(function(entry)
return not clink.is_dir(base_path..'/'..entry)
end)
-- if 'recursive' flag is not set, we don't need to iterate
-- through directories, so just return files found
if not recursive then return files end
local sep = reverse_separator and '/' or '\\'
return entries
:filter(function(entry)
return clink.is_dir(base_path..'/'..entry)
end)
:reduce(files, function(accum, dir)
-- iterate through directories and call list_files recursively
return exports.list_files(base_path..'/'..dir, mask, recursive, reverse_separator)
:map(function(entry)
return dir..sep..entry
end)
:concat(accum)
end)
end
exports.basename = function (path)
local prefix = path
local i = path:find("[\\/:][^\\/:]*$")
if i then
prefix = path:sub(i + 1)
end
return prefix
end
exports.pathname = function (path)
local prefix = ""
local i = path:find("[\\/:][^\\/:]*$")
if i then
prefix = path:sub(1, i-1)
end
return prefix
end
exports.is_metadir = function (dirname)
return exports.basename(dirname) == '.'
or exports.basename(dirname) == '..'
end
exports.is_real_dir = function (dirname)
return not exports.is_metadir(dirname)
end
return exports