Skip to content

Commit c109ef0

Browse files
committed
Support filepath >= 1.5.0.0 and os-string
1 parent 71e5648 commit c109ef0

File tree

6 files changed

+50
-8
lines changed

6 files changed

+50
-8
lines changed

System/Posix/Env/PosixString.hsc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE CApiFFI #-}
2+
{-# LANGUAGE PackageImports #-}
23

34
-----------------------------------------------------------------------------
45
-- |
@@ -42,7 +43,11 @@ import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
4243
import System.Posix.Env ( clearEnv )
4344
import System.OsPath.Posix
4445
import System.OsString.Internal.Types
45-
import qualified System.OsPath.Data.ByteString.Short as B
46+
#if MIN_VERSION_filepath(1, 5, 0)
47+
import qualified "os-string" System.OsString.Data.ByteString.Short as B
48+
#else
49+
import qualified "filepath" System.OsPath.Data.ByteString.Short as B
50+
#endif
4651
import Data.ByteString.Short.Internal ( copyToPtr )
4752

4853
import qualified System.Posix.Env.Internal as Internal

System/Posix/PosixPath/FilePath.hsc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE TypeApplications #-}
33
{-# LANGUAGE PatternSynonyms #-}
4+
{-# LANGUAGE PackageImports #-}
45

56
-----------------------------------------------------------------------------
67
-- |
@@ -45,7 +46,11 @@ import Data.ByteString.Internal (c_strlen)
4546
import Control.Monad
4647
import Control.Exception
4748
import System.OsPath.Posix as PS
48-
import System.OsPath.Data.ByteString.Short as BSS
49+
#if MIN_VERSION_filepath(1, 5, 0)
50+
import "os-string" System.OsString.Data.ByteString.Short as BSS
51+
#else
52+
import "filepath" System.OsPath.Data.ByteString.Short as BSS
53+
#endif
4954
import Prelude hiding (FilePath)
5055
import System.OsString.Internal.Types (PosixString(..), pattern PS)
5156
import GHC.IO.Exception

System/Posix/Process/PosixString.hsc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE PackageImports #-}
12
-----------------------------------------------------------------------------
23
-- |
34
-- Module : System.Posix.Process.PosixString
@@ -79,7 +80,11 @@ import Foreign.C hiding (
7980

8081
import System.OsPath.Types
8182
import System.OsString.Internal.Types (PosixString(..))
82-
import qualified System.OsPath.Data.ByteString.Short as BC
83+
#if MIN_VERSION_filepath(1, 5, 0)
84+
import qualified "os-string" System.OsString.Data.ByteString.Short as BC
85+
#else
86+
import qualified "filepath" System.OsPath.Data.ByteString.Short as BC
87+
#endif
8388

8489
import System.Posix.PosixPath.FilePath
8590

System/Posix/Temp/PosixString.hsc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE CApiFFI #-}
2+
{-# LANGUAGE PackageImports #-}
23
-----------------------------------------------------------------------------
34
-- |
45
-- Module : System.Posix.Temp.PosixString
@@ -20,7 +21,11 @@ module System.Posix.Temp.PosixString (
2021

2122
#include "HsUnix.h"
2223

23-
import qualified System.OsPath.Data.ByteString.Short as BC
24+
#if MIN_VERSION_filepath(1, 5, 0)
25+
import qualified "os-string" System.OsString.Data.ByteString.Short as BC
26+
#else
27+
import qualified "filepath" System.OsPath.Data.ByteString.Short as BC
28+
#endif
2429
import Data.Word
2530

2631
import Foreign.C

tests/T13660.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE OverloadedStrings #-}
3+
{-# LANGUAGE PackageImports #-}
34

45
module Main where
56

@@ -15,7 +16,11 @@ import System.Posix.IO (defaultFileFlags, OpenFileFlags(..), OpenMode(..))
1516
import System.Posix.ByteString.FilePath
1617

1718
import qualified Data.ByteString.Char8 as C
18-
import qualified System.OsPath.Data.ByteString.Short as SBS
19+
#if MIN_VERSION_filepath(1, 5, 0)
20+
import qualified "os-string" System.OsString.Data.ByteString.Short as SBS
21+
#else
22+
import qualified "filepath" System.OsPath.Data.ByteString.Short as SBS
23+
#endif
1924
import qualified System.Posix.Env.PosixString as PS
2025
import qualified System.Posix.IO.PosixString as PS
2126
import qualified System.Posix.IO.ByteString as BS

unix.cabal

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ extra-tmp-files:
4545
include/HsUnixConfig.h
4646
unix.buildinfo
4747

48+
flag os-string
49+
description: Use the new os-string package
50+
default: False
51+
manual: False
52+
4853
source-repository head
4954
type: git
5055
location: https://github.com/haskell/unix.git
@@ -71,9 +76,13 @@ library
7176
build-depends:
7277
base >= 4.12.0.0 && < 4.20,
7378
bytestring >= 0.9.2 && < 0.13,
74-
filepath >= 1.4.100.0 && < 1.5,
7579
time >= 1.9.1 && < 1.13
7680

81+
if flag(os-string)
82+
build-depends: filepath >= 1.5.0.0, os-string >= 2.0.0
83+
else
84+
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0
85+
7786
exposed-modules:
7887
System.Posix
7988
System.Posix.ByteString
@@ -172,7 +181,11 @@ test-suite unix-tests
172181
Signals001
173182
type: exitcode-stdio-1.0
174183
default-language: Haskell2010
175-
build-depends: base, bytestring, filepath, tasty, tasty-hunit, tasty-quickcheck, unix
184+
build-depends: base, bytestring, tasty, tasty-hunit, tasty-quickcheck, unix
185+
if flag(os-string)
186+
build-depends: filepath >= 1.5.0.0, os-string >= 2.0.0
187+
else
188+
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0
176189
ghc-options: -Wall -with-rtsopts=-V0
177190

178191
test-suite FdReadBuf001
@@ -362,5 +375,9 @@ test-suite T13660
362375
main-is: T13660.hs
363376
type: exitcode-stdio-1.0
364377
default-language: Haskell2010
365-
build-depends: base, unix, filepath >= 1.4.100.0 && < 1.5, bytestring
378+
build-depends: base, unix, bytestring
379+
if flag(os-string)
380+
build-depends: filepath >= 1.5.0.0, os-string >= 2.0.0
381+
else
382+
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0
366383
ghc-options: -Wall

0 commit comments

Comments
 (0)