diff options
Diffstat (limited to 'src/luarocks/path.lua')
| -rw-r--r-- | src/luarocks/path.lua | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index e236db01..ae9c7fae 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | -- point where the layout of the local installation is defined in LuaRocks. | 4 | -- point where the layout of the local installation is defined in LuaRocks. |
| 5 | module("luarocks.path", package.seeall) | 5 | module("luarocks.path", package.seeall) |
| 6 | 6 | ||
| 7 | local fs = require("luarocks.fs") | 7 | local dir = require("luarocks.dir") |
| 8 | local cfg = require("luarocks.cfg") | 8 | local cfg = require("luarocks.cfg") |
| 9 | 9 | ||
| 10 | --- Infer rockspec filename from a rock filename. | 10 | --- Infer rockspec filename from a rock filename. |
| @@ -12,7 +12,7 @@ local cfg = require("luarocks.cfg") | |||
| 12 | -- @return string: Filename of the rockspec, without path. | 12 | -- @return string: Filename of the rockspec, without path. |
| 13 | function rockspec_name_from_rock(rock_name) | 13 | function rockspec_name_from_rock(rock_name) |
| 14 | assert(type(rock_name) == "string") | 14 | assert(type(rock_name) == "string") |
| 15 | local base_name = fs.base_name(rock_name) | 15 | local base_name = dir.base_name(rock_name) |
| 16 | return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" | 16 | return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" |
| 17 | end | 17 | end |
| 18 | 18 | ||
| @@ -25,7 +25,7 @@ function versions_dir(name, repo) | |||
| 25 | assert(type(name) == "string") | 25 | assert(type(name) == "string") |
| 26 | assert(not repo or type(repo) == "string") | 26 | assert(not repo or type(repo) == "string") |
| 27 | 27 | ||
| 28 | return fs.make_path(repo or cfg.rocks_dir, name) | 28 | return dir.path(repo or cfg.rocks_dir, name) |
| 29 | end | 29 | end |
| 30 | 30 | ||
| 31 | --- Get the local installation directory (prefix) for a package. | 31 | --- Get the local installation directory (prefix) for a package. |
| @@ -39,7 +39,7 @@ function install_dir(name, version, repo) | |||
| 39 | assert(type(version) == "string") | 39 | assert(type(version) == "string") |
| 40 | assert(not repo or type(repo) == "string") | 40 | assert(not repo or type(repo) == "string") |
| 41 | 41 | ||
| 42 | return fs.make_path(repo or cfg.rocks_dir, name, version) | 42 | return dir.path(repo or cfg.rocks_dir, name, version) |
| 43 | end | 43 | end |
| 44 | 44 | ||
| 45 | --- Get the local filename of the rockspec of an installed rock. | 45 | --- Get the local filename of the rockspec of an installed rock. |
| @@ -53,7 +53,7 @@ function rockspec_file(name, version, repo) | |||
| 53 | assert(type(version) == "string") | 53 | assert(type(version) == "string") |
| 54 | assert(not repo or type(repo) == "string") | 54 | assert(not repo or type(repo) == "string") |
| 55 | 55 | ||
| 56 | return fs.make_path(repo or cfg.rocks_dir, name, version, name.."-"..version..".rockspec") | 56 | return dir.path(repo or cfg.rocks_dir, name, version, name.."-"..version..".rockspec") |
| 57 | end | 57 | end |
| 58 | 58 | ||
| 59 | --- Get the local installation directory for C libraries of a package. | 59 | --- Get the local installation directory for C libraries of a package. |
| @@ -67,7 +67,7 @@ function lib_dir(name, version, repo) | |||
| 67 | assert(type(version) == "string") | 67 | assert(type(version) == "string") |
| 68 | assert(not repo or type(repo) == "string") | 68 | assert(not repo or type(repo) == "string") |
| 69 | 69 | ||
| 70 | return fs.make_path(repo or cfg.rocks_dir, name, version, "lib") | 70 | return dir.path(repo or cfg.rocks_dir, name, version, "lib") |
| 71 | end | 71 | end |
| 72 | 72 | ||
| 73 | --- Get the local installation directory for Lua modules of a package. | 73 | --- Get the local installation directory for Lua modules of a package. |
| @@ -81,7 +81,7 @@ function lua_dir(name, version, repo) | |||
| 81 | assert(type(version) == "string") | 81 | assert(type(version) == "string") |
| 82 | assert(not repo or type(repo) == "string") | 82 | assert(not repo or type(repo) == "string") |
| 83 | 83 | ||
| 84 | return fs.make_path(repo or cfg.rocks_dir, name, version, "lua") | 84 | return dir.path(repo or cfg.rocks_dir, name, version, "lua") |
| 85 | end | 85 | end |
| 86 | 86 | ||
| 87 | --- Get the local installation directory for documentation of a package. | 87 | --- Get the local installation directory for documentation of a package. |
| @@ -95,7 +95,7 @@ function doc_dir(name, version, repo) | |||
| 95 | assert(type(version) == "string") | 95 | assert(type(version) == "string") |
| 96 | assert(not repo or type(repo) == "string") | 96 | assert(not repo or type(repo) == "string") |
| 97 | 97 | ||
| 98 | return fs.make_path(repo or cfg.rocks_dir, name, version, "doc") | 98 | return dir.path(repo or cfg.rocks_dir, name, version, "doc") |
| 99 | end | 99 | end |
| 100 | 100 | ||
| 101 | --- Get the local installation directory for configuration files of a package. | 101 | --- Get the local installation directory for configuration files of a package. |
| @@ -109,7 +109,7 @@ function conf_dir(name, version, repo) | |||
| 109 | assert(type(version) == "string") | 109 | assert(type(version) == "string") |
| 110 | assert(not repo or type(repo) == "string") | 110 | assert(not repo or type(repo) == "string") |
| 111 | 111 | ||
| 112 | return fs.make_path(repo or cfg.rocks_dir, name, version, "conf") | 112 | return dir.path(repo or cfg.rocks_dir, name, version, "conf") |
| 113 | end | 113 | end |
| 114 | 114 | ||
| 115 | --- Get the local installation directory for command-line scripts | 115 | --- Get the local installation directory for command-line scripts |
| @@ -124,7 +124,7 @@ function bin_dir(name, version, repo) | |||
| 124 | assert(type(version) == "string") | 124 | assert(type(version) == "string") |
| 125 | assert(not repo or type(repo) == "string") | 125 | assert(not repo or type(repo) == "string") |
| 126 | 126 | ||
| 127 | return fs.make_path(repo or cfg.rocks_dir, name, version, "bin") | 127 | return dir.path(repo or cfg.rocks_dir, name, version, "bin") |
| 128 | end | 128 | end |
| 129 | 129 | ||
| 130 | --- Extract name, version and arch of a rock filename. | 130 | --- Extract name, version and arch of a rock filename. |
| @@ -133,7 +133,7 @@ end | |||
| 133 | -- of rock, or nil if name could not be parsed | 133 | -- of rock, or nil if name could not be parsed |
| 134 | function parse_rock_name(rock_file) | 134 | function parse_rock_name(rock_file) |
| 135 | assert(type(rock_file) == "string") | 135 | assert(type(rock_file) == "string") |
| 136 | return fs.base_name(rock_file):match("(.*)-([^-]+-%d+)%.([^.]+)%.rock$") | 136 | return dir.base_name(rock_file):match("(.*)-([^-]+-%d+)%.([^.]+)%.rock$") |
| 137 | end | 137 | end |
| 138 | 138 | ||
| 139 | --- Extract name and version of a rockspec filename. | 139 | --- Extract name and version of a rockspec filename. |
| @@ -142,7 +142,7 @@ end | |||
| 142 | -- of rockspec, or nil if name could not be parsed | 142 | -- of rockspec, or nil if name could not be parsed |
| 143 | function parse_rockspec_name(rockspec_file) | 143 | function parse_rockspec_name(rockspec_file) |
| 144 | assert(type(rockspec_file) == "string") | 144 | assert(type(rockspec_file) == "string") |
| 145 | return fs.base_name(rockspec_file):match("(.*)-([^-]+-%d+)%.(rockspec)") | 145 | return dir.base_name(rockspec_file):match("(.*)-([^-]+-%d+)%.(rockspec)") |
| 146 | end | 146 | end |
| 147 | 147 | ||
| 148 | --- Make a rockspec or rock URL. | 148 | --- Make a rockspec or rock URL. |
| @@ -159,13 +159,13 @@ function make_url(pathname, name, version, arch) | |||
| 159 | 159 | ||
| 160 | local filename = name.."-"..version | 160 | local filename = name.."-"..version |
| 161 | if arch == "installed" then | 161 | if arch == "installed" then |
| 162 | filename = fs.make_path(name, version, filename..".rockspec") | 162 | filename = dir.path(name, version, filename..".rockspec") |
| 163 | elseif arch == "rockspec" then | 163 | elseif arch == "rockspec" then |
| 164 | filename = filename..".rockspec" | 164 | filename = filename..".rockspec" |
| 165 | else | 165 | else |
| 166 | filename = filename.."."..arch..".rock" | 166 | filename = filename.."."..arch..".rock" |
| 167 | end | 167 | end |
| 168 | return fs.make_path(pathname, filename) | 168 | return dir.path(pathname, filename) |
| 169 | end | 169 | end |
| 170 | 170 | ||
| 171 | --- Convert a pathname to a module identifier. | 171 | --- Convert a pathname to a module identifier. |
| @@ -180,7 +180,7 @@ function path_to_module(file) | |||
| 180 | 180 | ||
| 181 | local name = file:match("(.*)%."..cfg.lua_extension.."$") | 181 | local name = file:match("(.*)%."..cfg.lua_extension.."$") |
| 182 | if name then | 182 | if name then |
| 183 | name = name:gsub(fs.dir_separator, ".") | 183 | name = name:gsub(dir.separator, ".") |
| 184 | local init = name:match("(.*)%.init$") | 184 | local init = name:match("(.*)%.init$") |
| 185 | if init then | 185 | if init then |
| 186 | name = init | 186 | name = init |
| @@ -188,7 +188,7 @@ function path_to_module(file) | |||
| 188 | else | 188 | else |
| 189 | name = file:match("(.*)%."..cfg.lib_extension.."$") | 189 | name = file:match("(.*)%."..cfg.lib_extension.."$") |
| 190 | if name then | 190 | if name then |
| 191 | name = name:gsub(fs.dir_separator, ".") | 191 | name = name:gsub(dir.separator, ".") |
| 192 | end | 192 | end |
| 193 | end | 193 | end |
| 194 | return name | 194 | return name |
| @@ -200,7 +200,7 @@ end | |||
| 200 | -- @return string: A directory name using the platform's separator. | 200 | -- @return string: A directory name using the platform's separator. |
| 201 | function module_to_path(mod) | 201 | function module_to_path(mod) |
| 202 | assert(type(mod) == "string") | 202 | assert(type(mod) == "string") |
| 203 | return (mod:gsub("[^.]*$", ""):gsub("%.", fs.dir_separator)) | 203 | return (mod:gsub("[^.]*$", ""):gsub("%.", dir.separator)) |
| 204 | end | 204 | end |
| 205 | 205 | ||
| 206 | --- Set up path-related variables for a given rock. | 206 | --- Set up path-related variables for a given rock. |
