From f465b932dc1c539f89bdf10f27d704383ea690d9 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Tue, 25 May 2010 00:25:29 +0300 Subject: Reading symlinks under non-Windows platform Patch to detect symlinks and follow them in path normalization. Reduces my database by 30 fonts. Please test (especially on Mac OSX). --- otfl-font-nms.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 120d259..5064e89 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -473,17 +473,25 @@ end local function path_normalize(path) --[[ - path normalization: - - a\b\c -> a/b/c - - a/../b -> b - - /cygdrive/a/b -> a:/b + path normalization: + - a\b\c -> a/b/c + - a/../b -> b + - /cygdrive/a/b -> a:/b + - reading symlinks under non-Win32 + - using kpse.readable_file on Win32 --]] if os.type == "windows" or os.type == "msdos" or os.name == "cygwin" then + path = kpse.readable_file(path) path = path:gsub('\\', '/') path = path:lower() - -- for cygwin cases... path = path:gsub('^/cygdrive/(%a)/', '%1:/') end + if os.type ~= "windows" and os.type ~= "msdos" then + local dest = lfs.readlink(path) + if dest then + path = file.join(file.dirname(path), dest) + end + end path = file.collapse_path(path) return path end -- cgit v1.2.3