From fb8d1d2e3a95494b4a7b36c956ae65d05dd05832 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 10 Apr 2016 18:58:06 +0200 Subject: [PATCH] LIB: give the buffer size in fallbackCopy a name --- src/HSFM/FileSystem/FileOperations.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/HSFM/FileSystem/FileOperations.hs b/src/HSFM/FileSystem/FileOperations.hs index c5ba2d0..16c041d 100644 --- a/src/HSFM/FileSystem/FileOperations.hs +++ b/src/HSFM/FileSystem/FileOperations.hs @@ -59,6 +59,10 @@ import Foreign.C.Error , eINVAL , eNOSYS ) +import Foreign.C.Types + ( + CSize + ) import Foreign.Marshal.Alloc ( allocaBytes @@ -377,12 +381,14 @@ unsafeCopyFile cm from@(_ :/ RegFile {}) to@(_ :/ Dir {}) fn bracket (SPI.openFd dest SPI.WriteOnly (Just fileM) SPI.defaultFileFlags) SPI.closeFd - $ \dfd -> allocaBytes 8192 $ \buf -> + $ \dfd -> allocaBytes (fromIntegral bufSize) $ \buf -> write' sfd dfd buf 0 where + bufSize :: CSize + bufSize = 8192 write' :: Fd -> Fd -> Ptr Word8 -> Int -> IO Int write' sfd dfd buf totalsize = do - size <- SPB.fdReadBuf sfd buf 8192 + size <- SPB.fdReadBuf sfd buf bufSize if (size == 0) then return $ fromIntegral totalsize else do rsize <- SPB.fdWriteBuf dfd buf size