| |
|
| |
|
| | local dir = {}
|
| |
|
| | local core = require("luarocks.core.dir")
|
| |
|
| | dir.path = core.path
|
| | dir.split_url = core.split_url
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | function dir.base_name(pathname)
|
| | assert(type(pathname) == "string")
|
| |
|
| | local base = pathname:gsub("[/\\]*$", ""):match(".*[/\\]([^/\\]*)")
|
| | return base or pathname
|
| | end
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | function dir.dir_name(pathname)
|
| | assert(type(pathname) == "string")
|
| | return (pathname:gsub("/*$", ""):match("(.*)[/]+[^/]*")) or ""
|
| | end
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | function dir.normalize(name)
|
| | local protocol, pathname = dir.split_url(name)
|
| | pathname = pathname:gsub("\\", "/"):gsub("(.)/*$", "%1"):gsub("//", "/")
|
| | if protocol ~= "file" then pathname = protocol .."://"..pathname end
|
| | return pathname
|
| | end
|
| |
|
| |
|
| |
|
| | function dir.is_basic_protocol(protocol)
|
| | return protocol == "http" or protocol == "https" or protocol == "ftp" or protocol == "file"
|
| | end
|
| |
|
| | function dir.deduce_base_dir(url)
|
| |
|
| | local known_exts = {}
|
| | for _, ext in ipairs{"zip", "git", "tgz", "tar", "gz", "bz2"} do
|
| | known_exts[ext] = ""
|
| | end
|
| | local base = dir.base_name(url)
|
| | return (base:gsub("%.([^.]*)$", known_exts):gsub("%.tar", ""))
|
| | end
|
| |
|
| | return dir
|
| |
|