on master help sign in
Using unix-compat for file sizes
commit85d87f310d3f0e50eec6fb183a1cc313bd9d0ec7 authorMichael Snoyman <michael@snoyman.com> dateTue 11 Jan 2011, 18:56 (16 years ago) parent7078cc5
2 files changed+5−24
Network/Wai/Handler/Warp/Util.hs+4−20 warp.cabal+1−4
Network/Wai/Handler/Warp/Util.hs+4−20
@@ -10,27 +10,11 @@ import qualified Data.Map as Map
1010import Data.ByteString (ByteString)
1111import Language.Haskell.TH.Syntax (qRunIO, lift)
1212import qualified Data.ByteString.Char8 as S8
13+import System.PosixCompat.Files (getFileStatus, fileSize)
14+import System.Posix.Types (FileOffset)
1315
14−#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
15−
16−import System.Win32.File
17−
18−getFileSize :: FilePath -> IO Integer
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
32−
33−#endif
16+getFileSize :: FilePath -> IO FileOffset
17+getFileSize = fmap fileSize . getFileStatus
3418
3519mimeTypes :: Map.Map ByteString ByteString
3620mimeTypes =
warp.cabal+1−4
@@ -28,15 +28,12 @@ Library
2828 , sendfile >= 0.7.2 && < 0.8
2929 , containers >= 0.2 && < 0.5
3030 , template-haskell
31+ , unix-compat >= 0.2 && < 0.3
3132 if flag(network-bytestring)
3233 build-depends: network >= 2.2.1 && < 2.2.3
3334 , network-bytestring >= 0.1.3 && < 0.1.4
3435 else
3536 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
4037 Exposed-modules: Network.Wai.Handler.Warp
4138 Network.Wai.Handler.Warp.Util
4239 Other-modules: UtilHelper