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 11{-# LANGUAGE PatternGuards #-}
22{-# LANGUAGE TypeApplications #-}
3+ {-# LANGUAGE MultiWayIf #-}
34
45-- This template expects CPP definitions for:
56-- MODULE_NAME = Posix | Windows
@@ -667,9 +668,24 @@ splitFileName_ fp
667668 = (dirSlash, file)
668669 where
669670 (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)
671682 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
673689
674690-- | Set the filename.
675691--
You can’t perform that action at this time.
0 commit comments