@@ -645,15 +645,26 @@ splitFileName_ fp
645
645
-- or UNC location "\\?\UNC\foo", where path separator is a part of the drive name.
646
646
-- We can test this by trying dropDrive and falling back to splitDrive.
647
647
| isWindows
648
- , Just (s1, _s2, bs') <- uncons2 dirSlash
649
- , isPathSeparator s1
650
- -- If bs' is empty, then s2 as the last character of dirSlash must be a path separator,
651
- -- so we are in the middle of shared drive.
652
- -- Otherwise, since s1 is a path separator, we might be in the middle of UNC path.
653
- , null bs' || maybe False isIncompleteUNC (readDriveUNC dirSlash)
654
- = (fp, mempty )
648
+ = case uncons2 dirSlash of
649
+ Just (s1, s2, bs')
650
+ | isPathSeparator s1
651
+ -- If bs' is empty, then s2 as the last character of dirSlash must be a path separator,
652
+ -- so we are in the middle of shared drive.
653
+ -- Otherwise, since s1 is a path separator, we might be in the middle of UNC path.
654
+ , null bs' || maybe False isIncompleteUNC (readDriveUNC dirSlash)
655
+ -> (fp, mempty )
656
+ -- This handles inputs like "//?/A:" and "//?/A:foo"
657
+ | isPathSeparator s1
658
+ , isPathSeparator s2
659
+ , Just (s3, s4, bs'') <- uncons2 bs'
660
+ , s3 == _question
661
+ , isPathSeparator s4
662
+ , null bs''
663
+ , Just (drive, rest) <- readDriveLetter file
664
+ -> (dirSlash <> drive, rest)
665
+ _ -> (dirSlash, file)
655
666
| otherwise
656
- = (dirSlash, file)
667
+ = (dirSlash, file)
657
668
where
658
669
(dirSlash, file) = breakEnd isPathSeparator fp
659
670
0 commit comments