From 1ef80f51b9c764aae7b49d352d2c55b88e2abda3 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 12 Feb 2014 18:26:50 +0400 Subject: Add openInfoDict function --- src/System/Torrent/Storage.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/System/Torrent/Storage.hs b/src/System/Torrent/Storage.hs index 5315d9dc..003a4e98 100644 --- a/src/System/Torrent/Storage.hs +++ b/src/System/Torrent/Storage.hs @@ -24,6 +24,7 @@ module System.Torrent.Storage , Mode (..) , def , open + , openInfoDict , close , withStorage @@ -54,6 +55,7 @@ import Data.Conduit.Binary as C import Data.Conduit.List as C import Data.Typeable +import Data.Torrent import Data.Torrent.Bitfield as BF import Data.Torrent.Layout import Data.Torrent.Piece @@ -94,6 +96,11 @@ open mode s l | s <= 0 = throwIO (InvalidSize s) | otherwise = Storage mode s <$> mmapFiles mode l +-- | Like 'open', but use 'InfoDict' file layout. +openInfoDict :: Mode -> FilePath -> InfoDict -> IO Storage +openInfoDict mode rootPath InfoDict {..} = + open mode (piPieceLength idPieceInfo) (flatLayout rootPath idLayoutInfo) + -- | Unmaps all files forcefully. It is recommended but not required. close :: Storage -> IO () close Storage {..} = unmapFiles fileMap -- cgit v1.2.3