{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE NoImplicitPrelude #-}

module System.FilePath.FilePather.ByteString(
  fromFilePath
, readFileB
, writeFileB
, appendFileB
) where

import Control.Exception ( Exception )
import Data.ByteString( ByteString )
import qualified Data.ByteString as B
import System.FilePath.FilePather.ReadFilePath
    ( ReadFilePathT, tryReadFilePath )
import System.IO ( IO )

fromFilePath ::
  Exception e =>
  ReadFilePathT e IO ByteString
fromFilePath :: forall e. Exception e => ReadFilePathT e IO ByteString
fromFilePath =
  forall e a.
Exception e =>
(FilePath -> IO a) -> ReadFilePathT e IO a
tryReadFilePath FilePath -> IO ByteString
B.fromFilePath

readFileB ::
  Exception e =>
  ReadFilePathT e IO ByteString
readFileB :: forall e. Exception e => ReadFilePathT e IO ByteString
readFileB =
  forall e a.
Exception e =>
(FilePath -> IO a) -> ReadFilePathT e IO a
tryReadFilePath FilePath -> IO ByteString
B.readFile

writeFileB ::
  Exception e =>
  ByteString
  -> ReadFilePathT e IO ()
writeFileB :: forall e. Exception e => ByteString -> ReadFilePathT e IO ()
writeFileB ByteString
s =
  forall e a.
Exception e =>
(FilePath -> IO a) -> ReadFilePathT e IO a
tryReadFilePath (FilePath -> ByteString -> IO ()
`B.writeFile` ByteString
s)

appendFileB ::
  Exception e =>
  ByteString
  -> ReadFilePathT e IO ()
appendFileB :: forall e. Exception e => ByteString -> ReadFilePathT e IO ()
appendFileB ByteString
s =
  forall e a.
Exception e =>
(FilePath -> IO a) -> ReadFilePathT e IO a
tryReadFilePath (FilePath -> ByteString -> IO ()
`B.appendFile` ByteString
s)