Skip to content

Commit 6a1c98d

Browse files
committed
Fix W.splitFileName "\\\\?\\A:\\fred"
1 parent 21ba597 commit 6a1c98d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

System/FilePath/Internal.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,16 @@ splitFileName_ fp
648648
-- If bs' is empty, then s2 as the last character of dirSlash must be a path separator,
649649
-- so we are in the middle of shared drive.
650650
-- Otherwise, since s1 is a path separator, we might be in the middle of UNC path.
651-
, null bs' || maybe False (null . snd) (readDriveUNC dirSlash)
651+
, null bs' || maybe False isIncompleteUNC (readDriveUNC dirSlash)
652652
= (fp, mempty)
653653
| otherwise
654654
= (dirSlash, file)
655655
where
656656
(dirSlash, file) = breakEnd isPathSeparator fp
657657

658+
isIncompleteUNC (pref, suff) = null suff && not (hasPenultimateColon pref)
659+
hasPenultimateColon = maybe False (maybe False ((== _colon) . snd) . unsnoc . fst) . unsnoc
660+
658661
-- | Set the filename.
659662
--
660663
-- > replaceFileName "/directory/other.txt" "file.ext" == "/directory/file.ext"

0 commit comments

Comments
 (0)