(•ิ_•ิ)?
This commit is contained in:
parent
45f6086c69
commit
bdd857e491
29
app/Main.hs
29
app/Main.hs
@ -1,14 +1,29 @@
|
||||
module Main where
|
||||
|
||||
import System.PosixCompat.Types
|
||||
import System.PosixCompat.Files
|
||||
import System.Posix.Types ()
|
||||
import System.Posix.Files ()
|
||||
import System.Posix.Directory ( getWorkingDirectory )
|
||||
import System.Directory
|
||||
( pathIsSymbolicLink, doesFileExist, getFileSize, doesDirectoryExist )
|
||||
import System.Environment ()
|
||||
import Data.Functor ( (<&>) )
|
||||
import Control.Monad ( (<=<), filterM )
|
||||
import System.Directory.Extra ( listContents )
|
||||
|
||||
getFileSize :: FilePath -> IO FileOffset
|
||||
getFileSize = (fileSize <$>) . getFileStatus
|
||||
listFiles :: FilePath -> IO [FilePath]
|
||||
listFiles dir = filterM ((return . not) <=< pathIsSymbolicLink) =<< filterM doesFileExist =<< listContents dir
|
||||
|
||||
getFolderSize :: FilePath -> IO FileOffset
|
||||
getFolderSize path = undefined
|
||||
listDirectories :: FilePath -> IO [FilePath]
|
||||
listDirectories dir = filterM ((return . not) <=< pathIsSymbolicLink) =<< filterM doesDirectoryExist =<< listContents dir
|
||||
|
||||
getAllSubpaths :: FilePath -> IO [(FilePath, Integer)]
|
||||
getAllSubpaths x = do
|
||||
sub <- listDirectories x
|
||||
subFiles <- mapM getAllSubpaths sub
|
||||
local <- listFiles x >>= (\y -> mapM getFileSize y <&> zip y)
|
||||
return $ local ++ concat subFiles
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStrLn "Hello, Haskell!"
|
||||
a <- getWorkingDirectory
|
||||
print =<< getAllSubpaths a
|
||||
|
@ -71,7 +71,9 @@ executable hcdu
|
||||
-- Other library packages from which modules are imported.
|
||||
build-depends: base ^>=4.17.1.0
|
||||
, brick >= 1.9
|
||||
, unix-compat >= 0.7
|
||||
, unix
|
||||
, extra
|
||||
, directory
|
||||
|
||||
-- Directories containing source files.
|
||||
hs-source-dirs: app
|
||||
|
Loading…
Reference in New Issue
Block a user