packages feed

filepather-0.5: src/System/FilePath/FilePather/ByteString.hs

{-# 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 =
  tryReadFilePath B.fromFilePath

readFileB ::
  Exception e =>
  ReadFilePathT e IO ByteString
readFileB =
  tryReadFilePath B.readFile

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

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