diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-12 18:26:50 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-12 18:26:50 +0400 |
commit | 1ef80f51b9c764aae7b49d352d2c55b88e2abda3 (patch) | |
tree | 416dc846b22d944bc33f2e00778decc1407847cd /src/System/Torrent | |
parent | b3a7be20b973974317b7974ee9799a403e3cf8b4 (diff) |
Add openInfoDict function
Diffstat (limited to 'src/System/Torrent')
-rw-r--r-- | src/System/Torrent/Storage.hs | 7 |
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 | |||
54 | import Data.Conduit.List as C | 55 | import Data.Conduit.List as C |
55 | import Data.Typeable | 56 | import Data.Typeable |
56 | 57 | ||
58 | import Data.Torrent | ||
57 | import Data.Torrent.Bitfield as BF | 59 | import Data.Torrent.Bitfield as BF |
58 | import Data.Torrent.Layout | 60 | import Data.Torrent.Layout |
59 | import Data.Torrent.Piece | 61 | import 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. | ||
100 | openInfoDict :: Mode -> FilePath -> InfoDict -> IO Storage | ||
101 | openInfoDict 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. |
98 | close :: Storage -> IO () | 105 | close :: Storage -> IO () |
99 | close Storage {..} = unmapFiles fileMap | 106 | close Storage {..} = unmapFiles fileMap |