Skip to content
Snippets Groups Projects
Unverified Commit 071b6710 authored by Julian Ospald's avatar Julian Ospald :tea:
Browse files

Improve/rename dropExcessTrailingPathSeparators

parent 74713b96
No related branches found
No related tags found
No related merge requests found
......@@ -668,15 +668,12 @@ splitFileName_ fp
= (dirSlash, file)
where
(dirSlash, file) = breakEnd isPathSeparator fp
-- an adjustant variant of 'dropTrailingPathSeparator' that normalises trailing path separators
-- on windows
dropTrailingPathSeparator' x =
if hasTrailingPathSeparator x
then let x' = dropWhileEnd isPathSeparator x
in if | null x' -> singleton (last x)
| isDrive x -> addTrailingPathSeparator x'
| otherwise -> x'
else x
dropExcessTrailingPathSeparators x
| hasTrailingPathSeparator x
, let x' = dropWhileEnd isPathSeparator x
, otherwise = if | null x' -> singleton (last x)
| otherwise -> addTrailingPathSeparator x'
| otherwise = x
-- an "incomplete" UNC is one without a path (but potentially a drive)
isIncompleteUNC (pref, suff) = null suff && not (hasPenultimateColon pref)
......@@ -684,7 +681,7 @@ splitFileName_ fp
-- e.g. @//?/a:/@ or @//?/a://@, but not @//?/a:@
hasPenultimateColon pref
| hasTrailingPathSeparator pref
= maybe False (maybe False ((== _colon) . snd) . unsnoc . fst) . unsnoc . dropTrailingPathSeparator' $ pref
= maybe False (maybe False ((== _colon) . snd) . unsnoc . fst) . unsnoc . dropExcessTrailingPathSeparators $ pref
| otherwise = False
-- | Set the filename.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment