summaryrefslogtreecommitdiff
path: root/src/luaotfload-configuration.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-05-14 22:59:50 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2014-05-14 22:59:50 +0200
commitde2ebfd1e897e9bea9aee9ecffe1f146dd457adf (patch)
tree7e8b3037a345152ce93308d6c6419b03b5b1388d /src/luaotfload-configuration.lua
parent12547b5d6f57b0c8032b1029ed90352f5ac39bdb (diff)
downloadluaotfload-de2ebfd1e897e9bea9aee9ecffe1f146dd457adf.tar.gz
[conf,db,diagnose] reimplement runtime cache path handling as configuration task
Diffstat (limited to 'src/luaotfload-configuration.lua')
-rw-r--r--src/luaotfload-configuration.lua53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index 535db30..c806915 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -54,6 +54,8 @@ local lfsisdir = lfs.isdir
local file = file
local filejoin = file.join
+local filereplacesuffix = file.replacesuffix
+
local parsers = luaotfload.parsers
@@ -61,6 +63,9 @@ local log = luaotfload.log
local logreport = log.report
local config_parser = parsers.config
+local stripslashes = parsers.stripslashes
+
+local getwritablepath = caches.getwritablepath
-------------------------------------------------------------------------------
--- SETTINGS
@@ -106,10 +111,14 @@ local default_config = {
termwidth = nil,
},
paths = {
- names_dir = "names",
- cache_dir = "fonts",
- index_file = "luaotfload-names.lua",
- lookups_file = "luaotfload-lookup-cache.lua",
+ names_dir = "names",
+ cache_dir = "fonts",
+ index_file = "luaotfload-names.lua",
+ lookups_file = "luaotfload-lookup-cache.lua",
+ lookup_path_lua = nil,
+ lookup_path_luc = nil,
+ index_path_lua = nil,
+ index_path_luc = nil,
},
}
@@ -182,8 +191,32 @@ local set_loglevel = function ()
return true
end
+local build_cache_paths = function ()
+ local paths = config.luaotfload.paths
+ local prefix = getwritablepath (paths.names_dir, "")
+
+ if not prefix then
+ luaotfload.error ("Impossible to find a suitable writeable cache...")
+ return false
+ end
+
+ prefix = lpegmatch (stripslashes, prefix)
+ logreport ("log", 0, "conf", "Root cache directory is %s.", prefix)
+
+ local index_file = filejoin (prefix, paths.index_file)
+ local lookups_file = filejoin (prefix, paths.lookups_file)
+
+ paths.prefix = prefix
+ paths.index_path_lua = filereplacesuffix (index_file, "lua")
+ paths.index_path_luc = filereplacesuffix (index_file, "luc")
+ paths.lookup_path_lua = filereplacesuffix (lookups_file, "lua")
+ paths.lookup_path_luc = filereplacesuffix (lookups_file, "luc")
+ return true
+end
+
reconf_tasks = {
{ "Set the log level" , set_loglevel },
+ { "Build cache paths" , build_cache_paths },
{ "Check terminal dimensions" , check_termwidth },
{ "Set the font filter" , set_font_filter },
{ "Install font name resolver", set_name_resolver },
@@ -263,10 +296,14 @@ local option_spec = {
},
},
paths = {
- names_dir = { in_t = string_t, },
- cache_dir = { in_t = string_t, },
- index_file = { in_t = string_t, },
- lookups_file = { in_t = string_t, },
+ names_dir = { in_t = string_t, },
+ cache_dir = { in_t = string_t, },
+ index_file = { in_t = string_t, },
+ lookups_file = { in_t = string_t, },
+ lookup_path_lua = { in_t = string_t, },
+ lookup_path_luc = { in_t = string_t, },
+ index_path_lua = { in_t = string_t, },
+ index_path_luc = { in_t = string_t, },
},
}