X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=src%2FFuncTorrent%2FUtils.hs;h=b1db8d0defcbf9d6b1c9f46ec520448369b90b19;hb=ebc045715374d3418a0c1466f6ae95252603899c;hp=48ebe67710d81258b9600c874dec3de414d52cf5;hpb=5ad7d5cb250a61b3a889373d86d72a09c3f5ce22;p=functorrent.git diff --git a/src/FuncTorrent/Utils.hs b/src/FuncTorrent/Utils.hs index 48ebe67..b1db8d0 100644 --- a/src/FuncTorrent/Utils.hs +++ b/src/FuncTorrent/Utils.hs @@ -11,6 +11,7 @@ module FuncTorrent.Utils import Prelude hiding (writeFile, take) import qualified Crypto.Hash.SHA1 as SHA1 (hash) +import Control.Monad (unless) import Data.ByteString (ByteString, writeFile, hPut, hGet, take) import qualified Data.ByteString.Char8 as BC import System.IO (withFile, hSeek, IOMode(..), SeekMode(..)) @@ -28,9 +29,7 @@ splitNum n d | n == 0 = [] createDummyFile :: FilePath -> Int -> IO () createDummyFile path size = do dfe <- doesFileExist path - if dfe - then return () - else + unless dfe $ writeFile path (BC.replicate size '\0') -- write into a file at a specific offet