From 6a1c98dc5eb8021107d59903bbbb60137a6f9dbd Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Sat, 25 Feb 2023 00:19:05 +0000 Subject: [PATCH] Fix W.splitFileName "\\\\?\\A:\\fred" --- System/FilePath/Internal.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs index aff418d5..3f72d642 100644 --- a/System/FilePath/Internal.hs +++ b/System/FilePath/Internal.hs @@ -648,13 +648,16 @@ splitFileName_ fp -- If bs' is empty, then s2 as the last character of dirSlash must be a path separator, -- so we are in the middle of shared drive. -- Otherwise, since s1 is a path separator, we might be in the middle of UNC path. - , null bs' || maybe False (null . snd) (readDriveUNC dirSlash) + , null bs' || maybe False isIncompleteUNC (readDriveUNC dirSlash) = (fp, mempty) | otherwise = (dirSlash, file) where (dirSlash, file) = breakEnd isPathSeparator fp + isIncompleteUNC (pref, suff) = null suff && not (hasPenultimateColon pref) + hasPenultimateColon = maybe False (maybe False ((== _colon) . snd) . unsnoc . fst) . unsnoc + -- | Set the filename. -- -- > replaceFileName "/directory/other.txt" "file.ext" == "/directory/file.ext"