summaryrefslogtreecommitdiff
path: root/lib/Paths.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-30 02:02:29 +0200
committerstuebinm2021-09-30 02:02:29 +0200
commitca8552c4eb69b2b8267fe0046320bccf9f547b52 (patch)
treeefda222c28b3d6267c89dd8b1793e4c6c259e53d /lib/Paths.hs
parent68af04a4da6ba4ec61d1469337ce53457526d861 (diff)
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.
Diffstat (limited to 'lib/Paths.hs')
-rw-r--r--lib/Paths.hs7
1 files changed, 6 insertions, 1 deletions
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)