File size distribution: Difference between revisions
Content added Content deleted
(Add Factor) |
m (→{{header|Haskell}}: optimize file collection) |
||
Line 441: | Line 441: | ||
import GHC.Conc (getNumProcessors) |
import GHC.Conc (getNumProcessors) |
||
import System.Directory (doesDirectoryExist, doesFileExist, |
import System.Directory (doesDirectoryExist, doesFileExist, |
||
listDirectory, |
|||
pathIsSymbolicLink) |
pathIsSymbolicLink) |
||
import System.Environment (getArgs) |
import System.Environment (getArgs) |
||
Line 562: | Line 562: | ||
pure [] |
pure [] |
||
where |
where |
||
tryCollect = |
tryCollect = (fmap (folderPath </>) <$> listDirectory folderPath) >>= mapM f |
||
where |
|||
contents <- fmap (folderPath </>) <$> getDirectoryContents folderPath |
|||
f p = do |
|||
isFolder <- doesDirectoryExist p |
|||
if isFolder then |
|||
⚫ | |||
pure $ Folder p |
|||
else do |
|||
⚫ | |||
pure $ File p size |
|||
parallelItemCollector :: FilePath -> IO [Item] |
parallelItemCollector :: FilePath -> IO [Item] |