on master help sign in
Using unix-compat for file sizes
85d87f3Michael Snoyman
Network/Wai/Handler/Warp/Util.hs+4−20
@@ -10,27 +10,11 @@ import qualified Data.Map as Map
10import Data.ByteString (ByteString)
10import Data.ByteString (ByteString)
11import Language.Haskell.TH.Syntax (qRunIO, lift)
11import Language.Haskell.TH.Syntax (qRunIO, lift)
12import qualified Data.ByteString.Char8 as S8
12import qualified Data.ByteString.Char8 as S8
13+import System.PosixCompat.Files (getFileStatus, fileSize)
14+import System.Posix.Types (FileOffset)
13
15
14−#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
15−
16−import System.Win32.File
17−
18−getFileSize :: FilePath -> IO Integer
16+getFileSize :: FilePath -> IO FileOffset
19−getFileSize path = do
20− hnd <- createFile path
21− gENERIC_READ fILE_SHARE_READ Nothing oPEN_EXISTING 0 Nothing
22− size <- fmap bhfiSize $ getFileInformationByHandle hnd
23− closeHandle hnd
24− return $ fromIntegral size
25−
26−#else
27−
28−import System.Posix.Files
29−
30−getFileSize :: FilePath -> IO Integer
31−getFileSize = fmap (fromIntegral . fileSize) . getFileStatus
17+getFileSize = fmap fileSize . getFileStatus
32−
33−#endif
34
18
35mimeTypes :: Map.Map ByteString ByteString
19mimeTypes :: Map.Map ByteString ByteString
36mimeTypes =
20mimeTypes =
warp.cabal+1−4
@@ -28,15 +28,12 @@ Library
28 , sendfile >= 0.7.2 && < 0.8
28 , sendfile >= 0.7.2 && < 0.8
29 , containers >= 0.2 && < 0.5
29 , containers >= 0.2 && < 0.5
30 , template-haskell
30 , template-haskell
31+ , unix-compat >= 0.2 && < 0.3
31 if flag(network-bytestring)
32 if flag(network-bytestring)
32 build-depends: network >= 2.2.1 && < 2.2.3
33 build-depends: network >= 2.2.1 && < 2.2.3
33 , network-bytestring >= 0.1.3 && < 0.1.4
34 , network-bytestring >= 0.1.3 && < 0.1.4
34 else
35 else
35 build-depends: network >= 2.3 && < 2.4
36 build-depends: network >= 2.3 && < 2.4
36− if os(windows)
37− Build-Depends: Win32 >= 2.2 && < 2.3
38− else
39− Build-Depends: unix >= 2.4 && < 2.5
40 Exposed-modules: Network.Wai.Handler.Warp
37 Exposed-modules: Network.Wai.Handler.Warp
41 Network.Wai.Handler.Warp.Util
38 Network.Wai.Handler.Warp.Util
42 Other-modules: UtilHelper
39 Other-modules: UtilHelper