File size distribution: Difference between revisions

m
Line 426:
fileSizes = foldr f []
where
f (File _ n) acc = n : acc
f _ acc = acc
 
Line 509:
| n >= 2^30 && n <= 2^40 = display (2^30) "GB"
| n >= 2^40 && n <= 2^50 = display (2^40) "TB"
| otherwise = printf "%8dBToo large!" n
where
display :: Double -> String -> String
Line 519:
 
collectItems :: FilePath -> IO [Item]
collectItems folderPath = catch tryCollect $ \e -> do
(\e -> do
hPrintf stderr "Skipping: %s\n" $ show (e :: IOException)
pure [])
where
tryCollect = do
Line 559 ⟶ 558:
loop :: Chan FilePath -> Chan [Item] -> [Item] -> IO [Item]
loop folderChan resultItemsChan xs = do
letregularFolders fs<- filterM (pathIsSymbolicLink >=> (pure . not)) $ folders xs
regularFolders <- filterM (pathIsSymbolicLink >=> (pure . not)) fs
if null regularFolders then pure []
else do
Line 583 ⟶ 581:
putStrLn $ replicate 46 '-'
let results = expandedGroups groupSize (sizes items) (groupThreshold fileCount) items
-- let results = initialGroups groupSize items
mapM_ (displayFrequency fileCount) $ Map.assocs results
where
Anonymous user