From ca8552c4eb69b2b8267fe0046320bccf9f547b52 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 30 Sep 2021 02:02:29 +0200 Subject: simple map-map link dependency checking This is purely based on a set difference, i.e. it won't catch stupid things like a map linking to itself, a map link going only one-way, etc. Also, it only handles map links; it doesn't check if all ressource files referenced by a map actually exist. --- lib/Paths.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/Paths.hs') diff --git a/lib/Paths.hs b/lib/Paths.hs index 5044673..af66e77 100644 --- a/lib/Paths.hs +++ b/lib/Paths.hs @@ -35,8 +35,9 @@ parsePath text = else Nothing instance PrettyPrint RelPath where - prettyprint (Path up rest _) = ups <> rest + prettyprint (Path up rest frag) = ups <> rest <> fragment where ups = T.concat $ replicate up "../" + fragment = maybe mempty ("#" <>) frag -- | Normalises a path. -- @@ -48,3 +49,7 @@ normalise prefix (Path 0 path _) = prefix T.unpack path normalise prefix (Path i path _) = concat (take (length dirs - i) dirs) T.unpack path where dirs = splitPath prefix + +normaliseWithFrag :: FilePath -> RelPath -> FilePath +normaliseWithFrag prefix (Path i path frag) = + normalise prefix (Path (i+1) path frag) <> T.unpack (maybe mempty ("#" <>) frag) -- cgit v1.2.3