Mercurial > repo
comparison share/lua/5.2/luarocks/fs.lua @ 1132:d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
author | HackBot |
---|---|
date | Fri, 14 Dec 2012 22:24:27 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1131:ff65dfb63263 | 1132:d137f631bad5 |
---|---|
1 | |
2 --- Proxy module for filesystem and platform abstractions. | |
3 -- All code using "fs" code should require "luarocks.fs", | |
4 -- and not the various platform-specific implementations. | |
5 -- However, see the documentation of the implementation | |
6 -- for the API reference. | |
7 | |
8 local pairs = pairs | |
9 | |
10 module("luarocks.fs", package.seeall) | |
11 | |
12 local cfg = require("luarocks.cfg") | |
13 | |
14 local function load_fns(fs_table) | |
15 for name, fn in pairs(fs_table) do | |
16 if not _M[name] then | |
17 _M[name] = fn | |
18 end | |
19 end | |
20 end | |
21 | |
22 -- Load platform-specific functions | |
23 local loaded_platform = nil | |
24 for _, platform in ipairs(cfg.platforms) do | |
25 local ok, fs_plat = pcall(require, "luarocks.fs."..platform) | |
26 if ok and fs_plat then | |
27 loaded_platform = platform | |
28 load_fns(fs_plat) | |
29 break | |
30 end | |
31 end | |
32 | |
33 -- Load platform-independent pure-Lua functionality | |
34 local fs_lua = require("luarocks.fs.lua") | |
35 load_fns(fs_lua) | |
36 | |
37 -- Load platform-specific fallbacks for missing Lua modules | |
38 local ok, fs_plat_tools = pcall(require, "luarocks.fs."..loaded_platform..".tools") | |
39 if ok and fs_plat_tools then load_fns(fs_plat_tools) end | |
40 |