2023-08-01 22:41:27 +00:00
|
|
|
{- openFd wrapper to support old versions of unix package.
|
|
|
|
-
|
|
|
|
- Copyright 2023 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- License: BSD-2-clause
|
|
|
|
-}
|
|
|
|
|
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
|
|
|
|
2023-08-02 14:08:00 +00:00
|
|
|
module Utility.OpenFd where
|
|
|
|
|
|
|
|
#ifndef mingw32_HOST_OS
|
2023-08-01 22:41:27 +00:00
|
|
|
|
|
|
|
import System.Posix.IO.ByteString
|
|
|
|
import System.Posix.Types
|
|
|
|
import System.FilePath.ByteString (RawFilePath)
|
|
|
|
|
|
|
|
openFdWithMode :: RawFilePath -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd
|
|
|
|
#if MIN_VERSION_unix(2,8,0)
|
|
|
|
openFdWithMode f openmode filemode flags =
|
|
|
|
openFd f openmode (flags { creat = filemode })
|
|
|
|
#else
|
|
|
|
openFdWithMode = openFd
|
|
|
|
#endif
|
2023-08-02 14:08:00 +00:00
|
|
|
|
|
|
|
#endif
|