summaryrefslogtreecommitdiff
path: root/src/System/Torrent/Storage.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/System/Torrent/Storage.hs')
-rw-r--r--src/System/Torrent/Storage.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/System/Torrent/Storage.hs b/src/System/Torrent/Storage.hs
index 71e0616b..bf44d7bf 100644
--- a/src/System/Torrent/Storage.hs
+++ b/src/System/Torrent/Storage.hs
@@ -25,6 +25,7 @@ module System.Torrent.Storage
25 , def 25 , def
26 , open 26 , open
27 , close 27 , close
28 , withStorage
28 29
29 -- * Query 30 -- * Query
30 , genPieceInfo 31 , genPieceInfo
@@ -58,7 +59,7 @@ data StorageFailure
58 -- | Piece size do not match with one passed to the 'open' 59 -- | Piece size do not match with one passed to the 'open'
59 -- function. 60 -- function.
60 | InvalidSize PieceSize 61 | InvalidSize PieceSize
61 deriving (Show, Typeable) 62 deriving (Show, Eq, Typeable)
62 63
63instance Exception StorageFailure 64instance Exception StorageFailure
64 65
@@ -76,6 +77,10 @@ open mode s l = Storage mode s <$> mmapFiles mode l
76close :: Storage -> IO () 77close :: Storage -> IO ()
77close Storage {..} = unmapFiles fileMap 78close Storage {..} = unmapFiles fileMap
78 79
80withStorage :: Mode -> PieceSize -> FileLayout FileSize
81 -> (Storage -> IO ()) -> IO ()
82withStorage m s l = bracket (open m s l) close
83
79isValidIx :: PieceIx -> Storage -> Bool 84isValidIx :: PieceIx -> Storage -> Bool
80isValidIx i s = 0 <= i && i < undefined s 85isValidIx i s = 0 <= i && i < undefined s
81 86