summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-02 00:55:02 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-02 00:55:02 +0400
commit9a73e365f4c29080ab6ce04290b36e3189171289 (patch)
treef2657c41fbcc113b8e006a0b3a4f6891cea0c20e /src
parent10fcabb96e9f5b2d25cdfae22973cbcb99282139 (diff)
A little bit more informative ty syn name
Diffstat (limited to 'src')
-rw-r--r--src/Data/Torrent/Layout.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Data/Torrent/Layout.hs b/src/Data/Torrent/Layout.hs
index 8f35772d..54ec0f23 100644
--- a/src/Data/Torrent/Layout.hs
+++ b/src/Data/Torrent/Layout.hs
@@ -50,7 +50,7 @@ module Data.Torrent.Layout
50 , blockCount 50 , blockCount
51 51
52 -- * Flat file layout 52 -- * Flat file layout
53 , Layout 53 , FileLayout
54 , flatLayout 54 , flatLayout
55 , accumOffsets 55 , accumOffsets
56 , fileOffset 56 , fileOffset
@@ -286,13 +286,13 @@ blockCount blkSize ci = contentLength ci `sizeInBase` blkSize
286-- coalesce all the files in the given order to get the linear block 286-- coalesce all the files in the given order to get the linear block
287-- address space. 287-- address space.
288-- 288--
289type Layout a = [(FilePath, a)] 289type FileLayout a = [(FilePath, a)]
290 290
291-- | Extract files layout from torrent info with the given root path. 291-- | Extract files layout from torrent info with the given root path.
292flatLayout 292flatLayout
293 :: FilePath -- ^ Root path for the all torrent files. 293 :: FilePath -- ^ Root path for the all torrent files.
294 -> LayoutInfo -- ^ Torrent content information. 294 -> LayoutInfo -- ^ Torrent content information.
295 -> Layout FileSize -- ^ The all file paths prefixed with the given root. 295 -> FileLayout FileSize -- ^ The all file paths prefixed with the given root.
296flatLayout prefixPath SingleFile { liFile = FileInfo {..} } 296flatLayout prefixPath SingleFile { liFile = FileInfo {..} }
297 = [(prefixPath </> BC.unpack fiName, fiLength)] 297 = [(prefixPath </> BC.unpack fiName, fiLength)]
298flatLayout prefixPath MultiFile {..} = L.map mkPath liFiles 298flatLayout prefixPath MultiFile {..} = L.map mkPath liFiles
@@ -303,14 +303,14 @@ flatLayout prefixPath MultiFile {..} = L.map mkPath liFiles
303 </> joinPath (L.map BC.unpack fiName) 303 </> joinPath (L.map BC.unpack fiName)
304 304
305-- | Calculate offset of each file based on its length, incrementally. 305-- | Calculate offset of each file based on its length, incrementally.
306accumOffsets :: Layout FileSize -> Layout FileOffset 306accumOffsets :: FileLayout FileSize -> FileLayout FileOffset
307accumOffsets = go 0 307accumOffsets = go 0
308 where 308 where
309 go !_ [] = [] 309 go !_ [] = []
310 go !offset ((n, s) : xs) = (n, offset) : go (offset + s) xs 310 go !offset ((n, s) : xs) = (n, offset) : go (offset + s) xs
311 311
312-- | Gives global offset of a content file for a given full path. 312-- | Gives global offset of a content file for a given full path.
313fileOffset :: FilePath -> Layout FileOffset -> Maybe FileOffset 313fileOffset :: FilePath -> FileLayout FileOffset -> Maybe FileOffset
314fileOffset = lookup 314fileOffset = lookup
315{-# INLINE fileOffset #-} 315{-# INLINE fileOffset #-}
316 316