]> git.rkrishnan.org Git - functorrent.git/blobdiff - src/Main.hs
move torrentToMetainfo into Metainfo module
[functorrent.git] / src / Main.hs
index 7ba6d96c3bbe5884df4aab5b4de3e3a44278d700..f86e32c6849399d479ffb8f782ab821dd670f54f 100644 (file)
@@ -7,9 +7,8 @@ import System.Environment (getArgs)
 import System.Exit (exitSuccess)
 import System.Directory (doesFileExist)
 
-import FuncTorrent.Bencode (decode)
 import FuncTorrent.Logger (initLogger, logMessage, logStop)
-import FuncTorrent.Metainfo (Info(..), Metainfo(..), mkMetaInfo)
+import FuncTorrent.Metainfo (Info(..), Metainfo(..), torrentToMetainfo)
 import FuncTorrent.Peer (handShake, msgLoop)
 import FuncTorrent.Tracker (peers, getTrackerResponse)
 
@@ -34,14 +33,6 @@ parse [a] = do
     else error "file does not exist"
 parse _ = exit
 
-torrentToMetaInfo :: ByteString -> Either String Metainfo
-torrentToMetaInfo s =
-  case (decode s) of
-   Right d ->
-     mkMetaInfo d
-   Left e ->
-     Left $ show e
-
 main :: IO ()
 main = do
     args <- getArgs
@@ -50,7 +41,7 @@ main = do
     log "Starting up functorrent"
     log $ "Parsing arguments " ++ concat args
     torrentStr <- parse args
-    case (torrentToMetaInfo torrentStr) of
+    case (torrentToMetainfo torrentStr) of
      Right m -> do
        log "Input File OK"
        log $ "Downloading file : " ++ name (info m)