{-# LANGUAGE DeriveDataTypeable #-}-- |-- Module: System.FilePath.Internal-- Copyright: 2010 John Millikin-- License: MIT---- Maintainer: jmillikin@gmail.com-- Portability: portable--moduleSystem.FilePath.InternalwhereimportPreludehiding(FilePath)importqualifiedData.ByteStringasBimportqualifiedData.ByteString.Char8asB8importData.Data(Data)importData.Typeable(Typeable)--------------------------------------------------------------------------------- File Paths-------------------------------------------------------------------------------typeDirectory=B.ByteStringtypeBasename=B.ByteStringtypeExtension=B.ByteStringdataRoot=RootPosix|RootWindowsVolumeChar|RootWindowsCurrentVolumederiving(Eq,Ord,Data,Typeable)dataFilePath=FilePath{pathRoot::MaybeRoot,pathDirectories::[Directory],pathBasename::MaybeBasename,pathExtensions::[Extension]}deriving(Eq,Ord,Data,Typeable)-- | A file path with no root, directory, or filenameempty::FilePathempty=FilePathNothing[]Nothing[]filenameBytes::FilePath->B.ByteStringfilenameBytesp=B.appendnameextwherename=maybeB.emptyid(pathBasenamep)ext=casepathExtensionspof[]->B.emptyexts->B.intercalate(B8.pack".")(B.empty:exts)--------------------------------------------------------------------------------- Rules-------------------------------------------------------------------------------dataRules=Rules{rulesName::String,toByteChunks::FilePath->[B.ByteString]-- | Parse a strict 'B.ByteString', such as those received from-- OS libraries, into a 'FilePath'.,fromBytes::B.ByteString->FilePath-- | Check if a 'FilePath' is valid; it must not contain-- any illegal characters, and must have a root appropriate to the-- current 'Rules'.,valid::FilePath->Bool-- | Split a search path, such as @$PATH@ or @$PYTHONPATH@, into-- a list of 'FilePath's.,splitSearchPath::B.ByteString->[FilePath]}instanceShowRuleswhereshowsPrecdr=showParen(d>10)$showString"Rules ".shows(rulesNamer)