module System.File.PlatformPath where


import System.IO (IOMode(..), Handle)
import System.OsPath.Types

import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BSL

import qualified System.File.OsPath as OsPath
import System.OsString.Internal.Types

import Data.Coerce (coerce)

-- | Like `OsPath.openBinaryFile`, but takes a `PlatformPath` instead of an `OsPath`.
openBinaryFile :: PlatformPath -> IOMode -> IO Handle
openBinaryFile :: PlatformPath -> IOMode -> IO Handle
openBinaryFile = OsPath -> IOMode -> IO Handle
OsPath.openBinaryFile (OsPath -> IOMode -> IO Handle)
-> (PlatformPath -> OsPath) -> PlatformPath -> IOMode -> IO Handle
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.withFile`, but takes a `PlatformPath` instead of an `OsPath`.
withFile :: PlatformPath -> IOMode -> (Handle -> IO r) -> IO r
withFile :: forall r. PlatformPath -> IOMode -> (Handle -> IO r) -> IO r
withFile = OsPath -> IOMode -> (Handle -> IO r) -> IO r
forall r. OsPath -> IOMode -> (Handle -> IO r) -> IO r
OsPath.withFile (OsPath -> IOMode -> (Handle -> IO r) -> IO r)
-> (PlatformPath -> OsPath)
-> PlatformPath
-> IOMode
-> (Handle -> IO r)
-> IO r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.withBinaryFile`, but takes a `PlatformPath` instead of an `OsPath`.
withBinaryFile :: PlatformPath -> IOMode -> (Handle -> IO r) -> IO r
withBinaryFile :: forall r. PlatformPath -> IOMode -> (Handle -> IO r) -> IO r
withBinaryFile = OsPath -> IOMode -> (Handle -> IO r) -> IO r
forall r. OsPath -> IOMode -> (Handle -> IO r) -> IO r
OsPath.withBinaryFile (OsPath -> IOMode -> (Handle -> IO r) -> IO r)
-> (PlatformPath -> OsPath)
-> PlatformPath
-> IOMode
-> (Handle -> IO r)
-> IO r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.withFile'`, but takes a `PlatformPath` instead of an `OsPath`.
withFile' :: PlatformPath -> IOMode -> (Handle -> IO r) -> IO r
withFile' :: forall r. PlatformPath -> IOMode -> (Handle -> IO r) -> IO r
withFile' = OsPath -> IOMode -> (Handle -> IO r) -> IO r
forall r. OsPath -> IOMode -> (Handle -> IO r) -> IO r
OsPath.withFile' (OsPath -> IOMode -> (Handle -> IO r) -> IO r)
-> (PlatformPath -> OsPath)
-> PlatformPath
-> IOMode
-> (Handle -> IO r)
-> IO r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.withBinaryFile'`, but takes a `PlatformPath` instead of an `OsPath`.
withBinaryFile' :: PlatformPath -> IOMode -> (Handle -> IO r) -> IO r
withBinaryFile' :: forall r. PlatformPath -> IOMode -> (Handle -> IO r) -> IO r
withBinaryFile' = OsPath -> IOMode -> (Handle -> IO r) -> IO r
forall r. OsPath -> IOMode -> (Handle -> IO r) -> IO r
OsPath.withBinaryFile' (OsPath -> IOMode -> (Handle -> IO r) -> IO r)
-> (PlatformPath -> OsPath)
-> PlatformPath
-> IOMode
-> (Handle -> IO r)
-> IO r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.readFile`, but takes a `PlatformPath` instead of an `OsPath`.
readFile :: PlatformPath -> IO BSL.ByteString
readFile :: PlatformPath -> IO ByteString
readFile = OsPath -> IO ByteString
OsPath.readFile (OsPath -> IO ByteString)
-> (PlatformPath -> OsPath) -> PlatformPath -> IO ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.readFile'`, but takes a `PlatformPath` instead of an `OsPath`.
readFile' :: PlatformPath -> IO BS.ByteString
readFile' :: PlatformPath -> IO ByteString
readFile' = OsPath -> IO ByteString
OsPath.readFile' (OsPath -> IO ByteString)
-> (PlatformPath -> OsPath) -> PlatformPath -> IO ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.writeFile`, but takes a `PlatformPath` instead of an `OsPath`.
writeFile :: PlatformPath -> BSL.ByteString -> IO ()
writeFile :: PlatformPath -> ByteString -> IO ()
writeFile = OsPath -> ByteString -> IO ()
OsPath.writeFile (OsPath -> ByteString -> IO ())
-> (PlatformPath -> OsPath) -> PlatformPath -> ByteString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.writeFile'`, but takes a `PlatformPath` instead of an `OsPath`.
writeFile' :: PlatformPath -> BS.ByteString -> IO ()
writeFile' :: PlatformPath -> ByteString -> IO ()
writeFile' = OsPath -> ByteString -> IO ()
OsPath.writeFile' (OsPath -> ByteString -> IO ())
-> (PlatformPath -> OsPath) -> PlatformPath -> ByteString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.appendFile`, but takes a `PlatformPath` instead of an `OsPath`.
appendFile :: PlatformPath -> BSL.ByteString -> IO ()
appendFile :: PlatformPath -> ByteString -> IO ()
appendFile = OsPath -> ByteString -> IO ()
OsPath.appendFile (OsPath -> ByteString -> IO ())
-> (PlatformPath -> OsPath) -> PlatformPath -> ByteString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.appendFile'`, but takes a `PlatformPath` instead of an `OsPath`.
appendFile' :: PlatformPath -> BS.ByteString -> IO ()
appendFile' :: PlatformPath -> ByteString -> IO ()
appendFile' = OsPath -> ByteString -> IO ()
OsPath.appendFile' (OsPath -> ByteString -> IO ())
-> (PlatformPath -> OsPath) -> PlatformPath -> ByteString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.openFile`, but takes a `PlatformPath` instead of an `OsPath`.
openFile :: PlatformPath -> IOMode -> IO Handle
openFile :: PlatformPath -> IOMode -> IO Handle
openFile = OsPath -> IOMode -> IO Handle
OsPath.openFile (OsPath -> IOMode -> IO Handle)
-> (PlatformPath -> OsPath) -> PlatformPath -> IOMode -> IO Handle
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce

-- | Like `OsPath.openExistingFile`, but takes a `PlatformPath` instead of an `OsPath`.
openExistingFile :: PlatformPath -> IOMode -> IO Handle
openExistingFile :: PlatformPath -> IOMode -> IO Handle
openExistingFile = OsPath -> IOMode -> IO Handle
OsPath.openExistingFile (OsPath -> IOMode -> IO Handle)
-> (PlatformPath -> OsPath) -> PlatformPath -> IOMode -> IO Handle
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlatformPath -> OsPath
forall a b. Coercible a b => a -> b
coerce