From 22a3557ed14008a655d20ad216db22134442ed5b Mon Sep 17 00:00:00 2001 From: Sam T Date: Wed, 17 Jul 2013 04:08:20 +0400 Subject: + Add a few auxilaru functions. --- src/Data/Torrent.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Data') diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs index 8e837b56..a1df0034 100644 --- a/src/Data/Torrent.hs +++ b/src/Data/Torrent.hs @@ -33,7 +33,7 @@ module Data.Torrent -- * Files layout , Layout, contentLayout - , contentLength, fileOffset + , contentLength, fileCount, fileOffset , pieceCount, blockCount , isSingleFile, isMultiFile @@ -415,6 +415,11 @@ contentLength :: ContentInfo -> Integer contentLength SingleFile { ciLength = len } = len contentLength MultiFile { ciFiles = tfs } = sum (map fiLength tfs) +-- | Get count of all files in torrent. +fileCount :: ContentInfo -> Int +fileCount SingleFile {..} = 1 +fileCount MultiFile {..} = length ciFiles + -- | Find count of pieces in the torrent. If torrent size is not a -- multiple of piece size then the count is rounded up. pieceCount :: ContentInfo -> Int -- cgit v1.2.3