]> git.rkrishnan.org Git - functorrent.git/commitdiff
create a dummy file on the disk for a given path
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sun, 17 May 2015 07:53:04 +0000 (13:23 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sun, 17 May 2015 07:53:04 +0000 (13:23 +0530)
src/FuncTorrent/Peer.hs

index 481f5dac0b92b72fc0b85ed21442badd7444af24..d9ff9299ebe834ca2c0062d4e4e94ccecb98a0e1 100644 (file)
@@ -5,10 +5,10 @@ module FuncTorrent.Peer
      msgLoop
     ) where
 
      msgLoop
     ) where
 
-import Prelude hiding (lookup, concat, replicate, splitAt, empty)
+import Prelude hiding (lookup, concat, replicate, splitAt, empty, writeFile)
 
 
-import System.IO
-import Data.ByteString (ByteString, pack, unpack, concat, hGet, hPut, singleton)
+import System.IO (Handle, BufferMode(..), hSetBuffering)
+import Data.ByteString (ByteString, pack, unpack, concat, hGet, hPut, singleton, writeFile)
 import Data.ByteString.Lazy (fromStrict, fromChunks)
 import qualified Data.ByteString.Char8 as BC (replicate, pack, length)
 import Network (connectTo, PortID(..))
 import Data.ByteString.Lazy (fromStrict, fromChunks)
 import qualified Data.ByteString.Char8 as BC (replicate, pack, length)
 import Network (connectTo, PortID(..))
@@ -157,6 +157,12 @@ bitfieldToList bs = go bs 0
           in
            setBits ++ (go bs' (pos + 1))
 
           in
            setBits ++ (go bs' (pos + 1))
 
+-- downloadPiece :: Integer -> Handle -> IO ()
+
+createDummyFile :: FilePath -> Int -> IO ()
+createDummyFile path size = do
+  writeFile path (BC.replicate size '\0')
+
 -- loop1 :: shake hands with all peers, find out the pieces they have, form PieceData.
 -- recvMsg :: Peer -> Handle -> Msg
 msgLoop :: Handle -> ByteString -> IO ()
 -- loop1 :: shake hands with all peers, find out the pieces they have, form PieceData.
 -- recvMsg :: Peer -> Handle -> Msg
 msgLoop :: Handle -> ByteString -> IO ()