1 module FuncTorrent.Fileops
6 import Prelude hiding (writeFile)
8 import System.IO (withFile, hSeek, IOMode(..), SeekMode(..))
9 import Data.ByteString (ByteString, writeFile, hPut)
10 import qualified Data.ByteString.Char8 as BC (replicate)
12 createDummyFile :: FilePath -> Int -> IO ()
13 createDummyFile path size =
14 writeFile path (BC.replicate size '\0')
16 -- write into a file at a specific offet
17 writeFileAtOffset :: FilePath -> Integer -> ByteString -> IO ()
18 writeFileAtOffset path offset block =
19 withFile path ReadWriteMode (\h -> do
20 hSeek h AbsoluteSeek offset