DiskUsage Class Reference

#include <DiskUsage.h>

Collaboration diagram for DiskUsage:

Collaboration graph

List of all members.

Static Public Member Functions

static Params::UBigInt GetSize (const char *)
static void SetBlockSize (unsigned bs)
static Params::UBigInt AllocationSize (Params::UBigInt)
static Params::Size_t AllocationSize (Params::Size_t size)

Static Private Member Functions

static Params::UBigInt DepthFirstTraversal (const char *)

Static Private Attributes

static unsigned m_block_size
static const int m_max_path_name = 4096

Detailed Description

Provides a method to extract sizes of a given file or directory (recursively).

This class uses POSIX functions (lstat, chdir, opendir, closedir, S_ISDIR) and POSIX structures (stat, dirent). So, this class requires a POSIX-compatible environment to work.

Member Function Documentation

Params::UBigInt DiskUsage::GetSize ( const char *  filename  )  [static]

Returns the size of the given file or directory.

If the given file/directory could not be read then GetSize returns "0". Note: 0-sized files returns m_block_size.

References AllocationSize(), DepthFirstTraversal(), and m_max_path_name.

static void DiskUsage::SetBlockSize ( unsigned  bs  )  [inline, static]

Set the block size used by AllocationSize(Params::UBigInt).

References m_block_size.

Referenced by Input::Input().

Params::UBigInt DiskUsage::AllocationSize ( Params::UBigInt  size  )  [static]

This function returns the real size (allocated) of a given "size".

When size=0 then it occupies exactly m_block_size.

References m_block_size.

Referenced by AllocationSize(), DepthFirstTraversal(), and GetSize().

static Params::Size_t DiskUsage::AllocationSize ( Params::Size_t  size  )  [inline, static]

Same as AllocationSize(Params::UBigInt) but casts the given size to UBigInt datatype.

References AllocationSize().

Params::UBigInt DiskUsage::DepthFirstTraversal ( const char *  currdir  )  [static, private]

This function travels a given directory recursively.

Total size of the given directory.

References AllocationSize().

Referenced by GetSize().

Member Data Documentation

unsigned DiskUsage::m_block_size [static, private]

The smallest amount of bytes a file/directory can occupy.

Referenced by AllocationSize(), and SetBlockSize().

const int DiskUsage::m_max_path_name = 4096 [static, private]

Maximum size of a path name. This variable is used by the getcwd function.

Referenced by GetSize().

The documentation for this class was generated from the following files: