{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Filesystem.Path.CurrentOS
( module Filesystem.Path
, currentOS
, toText
, fromText
, encode
, decode
, encodeString
, decodeString
, valid
, splitSearchPath
, splitSearchPathString
) where
import Prelude hiding (FilePath)
import qualified Data.ByteString as B
import qualified Data.String as S
import qualified Data.Text as T
import Filesystem.Path
import qualified Filesystem.Path as F
import qualified Filesystem.Path.Rules as R
#if defined(__HADDOCK__)
# define PLATFORM_PATH_FORMAT platformTextFormat
#elif defined(CABAL_OS_WINDOWS) || defined(CABAL_OS_DARWIN)
# define PLATFORM_PATH_FORMAT T.Text
#else
# define PLATFORM_PATH_FORMAT B.ByteString
#endif
currentOS :: R.Rules PLATFORM_PATH_FORMAT
#if defined(__HADDOCK__)
currentOS :: forall platformTextFormat. Rules platformTextFormat
currentOS = forall a. HasCallStack => a
undefined
#elif defined(CABAL_OS_WINDOWS)
currentOS = R.windows
#elif defined(CABAL_OS_DARWIN)
#if __GLASGOW_HASKELL__ >= 702
currentOS = R.darwin_ghc702
#else
currentOS = R.darwin
#endif
#else
#if __GLASGOW_HASKELL__ >= 704
currentOS = R.posix_ghc704
#elif __GLASGOW_HASKELL__ >= 702
currentOS = R.posix_ghc702
#else
currentOS = R.posix
#endif
#endif
instance S.IsString F.FilePath where
fromString :: String -> FilePath
fromString = forall platformFormat. Rules platformFormat -> Text -> FilePath
R.fromText forall platformTextFormat. Rules platformTextFormat
currentOS forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack
instance Show F.FilePath where
showsPrec :: Int -> FilePath -> ShowS
showsPrec Int
d FilePath
path = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) (String -> ShowS
ss String
"FilePath " forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ShowS
s Text
txt) where
s :: Text -> ShowS
s = forall a. Show a => a -> ShowS
shows
ss :: String -> ShowS
ss = String -> ShowS
showString
txt :: Text
txt = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id (FilePath -> Either Text Text
toText FilePath
path)
toText :: F.FilePath -> Either T.Text T.Text
toText :: FilePath -> Either Text Text
toText = forall platformFormat.
Rules platformFormat -> FilePath -> Either Text Text
R.toText forall platformTextFormat. Rules platformTextFormat
currentOS
fromText :: T.Text -> F.FilePath
fromText :: Text -> FilePath
fromText = forall platformFormat. Rules platformFormat -> Text -> FilePath
R.fromText forall platformTextFormat. Rules platformTextFormat
currentOS
valid :: F.FilePath -> Bool
valid :: FilePath -> Bool
valid = forall platformFormat. Rules platformFormat -> FilePath -> Bool
R.valid forall platformTextFormat. Rules platformTextFormat
currentOS
splitSearchPath :: PLATFORM_PATH_FORMAT -> [F.FilePath]
splitSearchPath :: forall platformTextFormat. platformTextFormat -> [FilePath]
splitSearchPath = forall platformFormat.
Rules platformFormat -> platformFormat -> [FilePath]
R.splitSearchPath forall platformTextFormat. Rules platformTextFormat
currentOS
splitSearchPathString :: String -> [F.FilePath]
splitSearchPathString :: String -> [FilePath]
splitSearchPathString = forall platformFormat. Rules platformFormat -> String -> [FilePath]
R.splitSearchPathString forall platformTextFormat. Rules platformTextFormat
currentOS
encode :: F.FilePath -> PLATFORM_PATH_FORMAT
encode :: forall platformTextFormat. FilePath -> platformTextFormat
encode = forall platformFormat.
Rules platformFormat -> FilePath -> platformFormat
R.encode forall platformTextFormat. Rules platformTextFormat
currentOS
decode :: PLATFORM_PATH_FORMAT -> F.FilePath
decode :: forall platformTextFormat. platformTextFormat -> FilePath
decode = forall platformFormat.
Rules platformFormat -> platformFormat -> FilePath
R.decode forall platformTextFormat. Rules platformTextFormat
currentOS
encodeString :: F.FilePath -> String
encodeString :: FilePath -> String
encodeString = forall platformFormat. Rules platformFormat -> FilePath -> String
R.encodeString forall platformTextFormat. Rules platformTextFormat
currentOS
decodeString :: String -> F.FilePath
decodeString :: String -> FilePath
decodeString = forall platformFormat. Rules platformFormat -> String -> FilePath
R.decodeString forall platformTextFormat. Rules platformTextFormat
currentOS