{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances #-}moduleDevelopment.Shake.Internal.FileName(FileName ,fileNameFromString ,fileNameFromByteString ,fileNameToString ,fileNameToByteString ,filepathNormalise )whereimportqualifiedData.ByteString.Char8asBSimportqualifiedData.ByteString.UTF8asUTF8importDevelopment.Shake.Classes importqualifiedSystem.FilePathasNativeimportGeneral.Binary importSystem.Info.ExtraimportData.List----------------------------------------------------------------------- FileName newtype-- | UTF8 ByteStringnewtypeFileName =FileName BS.ByteStringderiving(Hashable,Binary,BinaryEx ,Eq,NFData)instanceShowFileName whereshow =fileNameToString instanceBinaryEx [FileName ]whereputEx =putEx .map(\(FileName x )->x )getEx =mapFileName .getEx fileNameToString::FileName ->FilePathfileNameToString =UTF8.toString.fileNameToByteString fileNameToByteString::FileName ->BS.ByteStringfileNameToByteString (FileName x )=x fileNameFromString::FilePath->FileName fileNameFromString =fileNameFromByteString .UTF8.fromStringfileNameFromByteString::BS.ByteString->FileName fileNameFromByteString =FileName .filepathNormalise ----------------------------------------------------------------------- NORMALISATION-- | Equivalent to @toStandard . normaliseEx@ from "Development.Shake.FilePath".filepathNormalise::BS.ByteString->BS.ByteStringfilepathNormalise xs |isWindows,Just(a ,xs )<-BS.unconsxs ,sep a ,Just(b ,_)<-BS.unconsxs ,sep b ='/'`BS.cons`f xs |otherwise=f xs wheresep =Native.isPathSeparatorf o =deslash o $BS.concat$(slash :)$intersperseslash $reverse$(BS.empty:)$g 0$reverse$split o deslash o x |x ==slash =case(pre ,pos )of(True,True)->slash (True,False)->BS.pack"/."(False,True)->BS.pack"./"(False,False)->dot |otherwise=(ifpre thenidelseBS.tail)$(ifpos thenidelseBS.init)x wherepre =not(BS.nullo )&&sep (BS.heado )pos =not(BS.nullo )&&sep (BS.lasto )g i []=replicatei dotDot gi (x :xs )|BS.nullx =g i xs gi (x :xs )|x ==dotDot =g (i +1)xs gi (x :xs )|x ==dot =g i xs g0(x :xs )=x :g 0xs gi (_:xs )=g (i -1)xs -- equivalent to eliminating ../xsplit =BS.splitWithsep dotDot =BS.pack".."dot =BS.singleton'.'slash =BS.singleton'/'

AltStyle によって変換されたページ (->オリジナル) /