File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
{-# LANGUAGE PatternGuards #-}
2
2
{-# LANGUAGE TypeApplications #-}
3
+ {-# LANGUAGE MultiWayIf #-}
3
4
4
5
-- This template expects CPP definitions for:
5
6
-- MODULE_NAME = Posix | Windows
@@ -667,9 +668,24 @@ splitFileName_ fp
667
668
= (dirSlash, file)
668
669
where
669
670
(dirSlash, file) = breakEnd isPathSeparator fp
670
-
671
+ -- an adjustant variant of 'dropTrailingPathSeparator' that normalises trailing path separators
672
+ -- on windows
673
+ dropTrailingPathSeparator' x =
674
+ if hasTrailingPathSeparator x
675
+ then let x' = dropWhileEnd isPathSeparator x
676
+ in if | null x' -> singleton (last x)
677
+ | isDrive x -> addTrailingPathSeparator x'
678
+ | otherwise -> x'
679
+ else x
680
+
681
+ -- an "incomplete" UNC is one without a path (but potentially a drive)
671
682
isIncompleteUNC (pref, suff) = null suff && not (hasPenultimateColon pref)
672
- hasPenultimateColon = maybe False (maybe False ((== _colon) . snd ) . unsnoc . fst ) . unsnoc
683
+
684
+ -- e.g. @//?/a:/@ or @//?/a://@, but not @//?/a:@
685
+ hasPenultimateColon pref
686
+ | hasTrailingPathSeparator pref
687
+ = maybe False (maybe False ((== _colon) . snd ) . unsnoc . fst ) . unsnoc . dropTrailingPathSeparator' $ pref
688
+ | otherwise = False
673
689
674
690
-- | Set the filename.
675
691
--
You can’t perform that action at this time.
0 commit comments