{- | Module : System.Path Copyright : (c) Galois Connections 2001-2004 Maintainer : lib@galois.com Stability : Portability : Platform specific path definitions. -} module System.Path ( pathSep -- :: Char , canonPath -- :: String -> String , isPathSeparator -- :: Char -> Bool , drivePath -- :: FilePath -> Maybe Char , isSeparator -- :: Char -> Bool ) where -- | preferred path separator for the platform. pathSep :: Char pathSep = '\\' -- | given a filepath, POSIX or otherwise, convert it into a -- platform-friendly form. canonPath :: FilePath -> FilePath canonPath xs = map toBwd xs where toBwd '/' = '\\' toBwd x = x -- | returns 'True' if character is a separator\/divider in a filepath. isSeparator :: Char -> Bool isSeparator = isPathSeparator -- deprecated (but I'll resist the temptation of -- adding an annoying deprecated pragma.) isPathSeparator :: Char -> Bool isPathSeparator '/' = True isPathSeparator '\\' = True isPathSeparator _ = False -- | return drive portion part of path, if any (and meaningful.) drivePath :: FilePath -> Maybe Char drivePath (x:':':s:_) | isPathSeparator s = Just x drivePath _ = Nothing