path-size-0.1: Utility for reporting file-system sizes.
Safe HaskellNone
LanguageGHC2021

PathSize

Description

Since: 0.1

Synopsis

Types

data PathData Source #

Associates a path to its total (recursive) size in the file-system. Takes a parameter for the size, allowing us to use a more efficient temporary type (e.g. Integer) before finally converting to Natural.

Since: 0.1

Constructors

MkPathData 

Fields

Instances

Instances details
Generic PathData Source # 
Instance details

Defined in PathSize.Data.PathData

Associated Types

type Rep PathData

Since: path-size-0.1

Instance details

Defined in PathSize.Data.PathData

type Rep PathData = D1 ('MetaData "PathData" "PathSize.Data.PathData" "path-size-0.1-inplace" 'False) (C1 ('MetaCons "MkPathData" 'PrefixI 'True) ((S1 ('MetaSel ('Just "path") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OsPath) :*: S1 ('MetaSel ('Just "size") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Integer)) :*: (S1 ('MetaSel ('Just "numFiles") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Integer) :*: S1 ('MetaSel ('Just "numDirectories") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Integer))))

Methods

from :: PathData -> Rep PathData x #

to :: Rep PathData x -> PathData #

Show PathData Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathData

NFData PathData Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathData

Methods

rnf :: PathData -> () #

Eq PathData Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathData

(k ~ A_Lens, a ~ Integer, b ~ Integer) => LabelOptic "numDirectories" k PathData PathData a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathData

(k ~ A_Lens, a ~ Integer, b ~ Integer) => LabelOptic "numFiles" k PathData PathData a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathData

(k ~ A_Lens, a ~ OsPath, b ~ OsPath) => LabelOptic "path" k PathData PathData a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathData

(k ~ A_Lens, a ~ Integer, b ~ Integer) => LabelOptic "size" k PathData PathData a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathData

LabelOptic "unSubPathData" A_Getter SubPathData SubPathData (NESeq PathData) (NESeq PathData) Source #

Since: 0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

HasField "unSubPathData" SubPathData (NESeq PathData) Source #

Since: 0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

type Rep PathData Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathData

type Rep PathData = D1 ('MetaData "PathData" "PathSize.Data.PathData" "path-size-0.1-inplace" 'False) (C1 ('MetaCons "MkPathData" 'PrefixI 'True) ((S1 ('MetaSel ('Just "path") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OsPath) :*: S1 ('MetaSel ('Just "size") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Integer)) :*: (S1 ('MetaSel ('Just "numFiles") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Integer) :*: S1 ('MetaSel ('Just "numDirectories") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Integer))))

data SubPathData where Source #

A flattened and sorted representation of PathTree. Contains at least one element.

Since: 0.1

Bundled Patterns

pattern MkSubPathData :: NESeq PathData -> SubPathData

Pattern synonym for SubPathData. Note that construction sorts the underlying NESeq, so it is not constant.

Since: 0.1

Instances

Instances details
Generic SubPathData Source # 
Instance details

Defined in PathSize.Data.SubPathData.Internal

Associated Types

type Rep SubPathData

Since: path-size-0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

type Rep SubPathData = D1 ('MetaData "SubPathData" "PathSize.Data.SubPathData.Internal" "path-size-0.1-inplace" 'True) (C1 ('MetaCons "UnsafeSubPathData" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NESeq PathData))))
Show SubPathData Source #

Since: 0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

NFData SubPathData Source #

Since: 0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

Methods

rnf :: SubPathData -> () #

Eq SubPathData Source #

Since: 0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

LabelOptic "unSubPathData" A_Getter SubPathData SubPathData (NESeq PathData) (NESeq PathData) Source #

Since: 0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

HasField "unSubPathData" SubPathData (NESeq PathData) Source #

Since: 0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

type Rep SubPathData Source #

Since: 0.1

Instance details

Defined in PathSize.Data.SubPathData.Internal

type Rep SubPathData = D1 ('MetaData "SubPathData" "PathSize.Data.SubPathData.Internal" "path-size-0.1-inplace" 'True) (C1 ('MetaCons "UnsafeSubPathData" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NESeq PathData))))

data PathSizeResult a Source #

Result of running a path-size computation with multiple notions of failure.

Since: 0.1

Constructors

PathSizeSuccess !a

Successfully computed a.

Since: 0.1

PathSizePartial !(NESeq PathE) !a

Computed a with some errors.

Since: 0.1

PathSizeFailure !(NESeq PathE)

Failed computing a.

Since: 0.1

Instances

Instances details
Functor PathSizeResult Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathSizeResult

Methods

fmap :: (a -> b) -> PathSizeResult a -> PathSizeResult b #

(<$) :: a -> PathSizeResult b -> PathSizeResult a #

Generic (PathSizeResult a) Source # 
Instance details

Defined in PathSize.Data.PathSizeResult

Associated Types

type Rep (PathSizeResult a)

Since: path-size-0.1

Instance details

Defined in PathSize.Data.PathSizeResult

type Rep (PathSizeResult a) = D1 ('MetaData "PathSizeResult" "PathSize.Data.PathSizeResult" "path-size-0.1-inplace" 'False) (C1 ('MetaCons "PathSizeSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: (C1 ('MetaCons "PathSizePartial" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NESeq PathE)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "PathSizeFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NESeq PathE)))))
Show a => Show (PathSizeResult a) Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathSizeResult

NFData a => NFData (PathSizeResult a) Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathSizeResult

Methods

rnf :: PathSizeResult a -> () #

Eq a => Eq (PathSizeResult a) Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathSizeResult

type Rep (PathSizeResult a) Source #

Since: 0.1

Instance details

Defined in PathSize.Data.PathSizeResult

type Rep (PathSizeResult a) = D1 ('MetaData "PathSizeResult" "PathSize.Data.PathSizeResult" "path-size-0.1-inplace" 'False) (C1 ('MetaCons "PathSizeSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: (C1 ('MetaCons "PathSizePartial" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NESeq PathE)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "PathSizeFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NESeq PathE)))))

Configuration

data Config Source #

Since: 0.1

Constructors

MkConfig 

Fields

  • searchAll :: !Bool

    Whether to search hidden files/directories.

    Since: 0.1

  • maxDepth :: !(Maybe Word16)

    The depth limit of our search. Note that we still need to fully traverse the file system to get accurate data; this argument merely affects what is reported i.e. any depths > d are implicitly included in parent directories, but not directly.

  • exclude :: !(HashSet OsPath)

    Paths to skip.

    Since: 0.1

  • filesOnly :: !Bool

    Whether to limit our search to just files.

    Since: 0.1

  • ignoreDirIntrinsicSize :: !Bool

    If active, this flag ignores the size of the directory itself e.g. 4096 bytes on a typical ext4 filesystem.

    Since: 0.1

  • numPaths :: !(Maybe (Positive Int))

    The number of paths to return.

    Since: 0.1

  • stableSort :: !Bool

    If enabled, sorts by path name after the size. This makes the sort stable, at the cost of performance.

    Since: 0.1

  • strategy :: !Strategy

    The search strategy.

    Since: 0.1

Instances

Instances details
Show Config Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

Eq Config Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

(k ~ A_Lens, a ~ HashSet OsPath, b ~ HashSet OsPath) => LabelOptic "exclude" k Config Config a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

(k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "filesOnly" k Config Config a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

(k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "ignoreDirIntrinsicSize" k Config Config a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

(k ~ A_Lens, a ~ Maybe Word16, b ~ Maybe Word16) => LabelOptic "maxDepth" k Config Config a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

(k ~ A_Lens, a ~ Maybe (Positive Int), b ~ Maybe (Positive Int)) => LabelOptic "numPaths" k Config Config a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

(k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "searchAll" k Config Config a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

(k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "stableSort" k Config Config a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

(k ~ A_Lens, a ~ Strategy, b ~ Strategy) => LabelOptic "strategy" k Config Config a b Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

data Strategy Source #

Describes the path search strategy.

Since: 0.1

Constructors

Sync

No threads.

Since: 0.1

Async

Lightweight threads.

Since: 0.1

AsyncPool

Uses a thread pool.

Since: 0.1

Instances

Instances details
Bounded Strategy Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

Enum Strategy Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

Show Strategy Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

Eq Strategy Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

Ord Strategy Source #

Since: 0.1

Instance details

Defined in PathSize.Data.Config

High level functions

findLargestPaths Source #

Arguments

:: (HasCallStack, MonadAsync m, MonadCatch m, MonadPathReader m, MonadPosixC m) 
=> Config

Configuration.

-> OsPath

OsPath to search.

-> m (PathSizeResult SubPathData)

The results.

Given a path, finds the size of all subpaths, recursively.

Since: 0.1

pathSizeRecursive :: (HasCallStack, MonadAsync m, MonadCatch m, MonadPathReader m, MonadPosixC m) => OsPath -> m (PathSizeResult Integer) Source #

Returns the total path size in bytes. Calls pathSizeRecursiveConfig with the following config:

MkConfig
  { searchAll = True,
    maxDepth = Just 0,
    exclude = [],
    filesOnly = False,
    ignoreDirIntrinsicSize = False,
    numPaths = Just 1,
    stableSort = False,
    strategy = Async
  }

Since: 0.1

pathSizeRecursiveConfig :: (HasCallStack, MonadAsync m, MonadCatch m, MonadPathReader m, MonadPosixC m) => Config -> OsPath -> m (PathSizeResult Integer) Source #

Returns the total path size in bytes.

Since: 0.1

display :: Bool -> SubPathData -> Text Source #

Displays the data.

Since: 0.1

Errors

data PathE Source #

Exception for a path. The second param is the reason i.e. the exceptions' displayException. The reason we convert to a string rather than leave it as an exception is so we can have an NFData instance for benchmarking.

Since: 0.1

Constructors

MkPathE !OsPath !String 

Instances

Instances details
Exception PathE Source #

Since: 0.1

Instance details

Defined in PathSize.Exception

Generic PathE Source # 
Instance details

Defined in PathSize.Exception

Associated Types

type Rep PathE

Since: path-size-0.1

Instance details

Defined in PathSize.Exception

Methods

from :: PathE -> Rep PathE x #

to :: Rep PathE x -> PathE #

Show PathE Source #

Since: 0.1

Instance details

Defined in PathSize.Exception

Methods

showsPrec :: Int -> PathE -> ShowS #

show :: PathE -> String #

showList :: [PathE] -> ShowS #

NFData PathE Source #

Since: 0.1

Instance details

Defined in PathSize.Exception

Methods

rnf :: PathE -> () #

Eq PathE Source #

Since: 0.1

Instance details

Defined in PathSize.Exception

Methods

(==) :: PathE -> PathE -> Bool #

(/=) :: PathE -> PathE -> Bool #

Ord PathE Source #

Since: 0.1

Instance details

Defined in PathSize.Exception

Methods

compare :: PathE -> PathE -> Ordering #

(<) :: PathE -> PathE -> Bool #

(<=) :: PathE -> PathE -> Bool #

(>) :: PathE -> PathE -> Bool #

(>=) :: PathE -> PathE -> Bool #

max :: PathE -> PathE -> PathE #

min :: PathE -> PathE -> PathE #

type Rep PathE Source #

Since: 0.1

Instance details

Defined in PathSize.Exception