summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-12 18:26:50 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-12 18:26:50 +0400
commit1ef80f51b9c764aae7b49d352d2c55b88e2abda3 (patch)
tree416dc846b22d944bc33f2e00778decc1407847cd /src
parentb3a7be20b973974317b7974ee9799a403e3cf8b4 (diff)
Add openInfoDict function
Diffstat (limited to 'src')
-rw-r--r--src/System/Torrent/Storage.hs7
1 files changed, 7 insertions, 0 deletions
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
24 , Mode (..) 24 , Mode (..)
25 , def 25 , def
26 , open 26 , open
27 , openInfoDict
27 , close 28 , close
28 , withStorage 29 , withStorage
29 30
@@ -54,6 +55,7 @@ import Data.Conduit.Binary as C
54import Data.Conduit.List as C 55import Data.Conduit.List as C
55import Data.Typeable 56import Data.Typeable
56 57
58import Data.Torrent
57import Data.Torrent.Bitfield as BF 59import Data.Torrent.Bitfield as BF
58import Data.Torrent.Layout 60import Data.Torrent.Layout
59import Data.Torrent.Piece 61import Data.Torrent.Piece
@@ -94,6 +96,11 @@ open mode s l
94 | s <= 0 = throwIO (InvalidSize s) 96 | s <= 0 = throwIO (InvalidSize s)
95 | otherwise = Storage mode s <$> mmapFiles mode l 97 | otherwise = Storage mode s <$> mmapFiles mode l
96 98
99-- | Like 'open', but use 'InfoDict' file layout.
100openInfoDict :: Mode -> FilePath -> InfoDict -> IO Storage
101openInfoDict mode rootPath InfoDict {..} =
102 open mode (piPieceLength idPieceInfo) (flatLayout rootPath idLayoutInfo)
103
97-- | Unmaps all files forcefully. It is recommended but not required. 104-- | Unmaps all files forcefully. It is recommended but not required.
98close :: Storage -> IO () 105close :: Storage -> IO ()
99close Storage {..} = unmapFiles fileMap 106close Storage {..} = unmapFiles fileMap