<filename>Python/empire/fs/structs/disk_usage.py
from empire.core import *
from empire.structs.structs import Struct
from empire.bit.units import UnitsUtil, DataSizeUnitsEnum


class DiskUsage(Struct):
    def __init__(self, raw: Any = None):
        super().__init__()
        self._total: int = 0
        self._used: int = 0
        self._free: int = 0
        super().__fields_decl_end__()
        self.assign_values(raw)

    @property
    def total_bytes(self) -> int:
        return self._total

    @property
    def used_bytes(self) -> int:
        return self._used

    @property
    def free_bytes(self) -> int:
        return self._free

    @property
    def total_readable(self) -> str:
        result = UnitsUtil.time_convert_to_best(self._total, DataSizeUnitsEnum.BYTE)
        return '{} {}'.format(result[0], result[1][2])

    @property
    def used_readable(self) -> str:
        result = UnitsUtil.time_convert_to_best(self._used, DataSizeUnitsEnum.BYTE)
        return '{} {}'.format(result[0], result[1][2])

    @property
    def free_readable(self) -> str:
        result = UnitsUtil.time_convert_to_best(self._free, DataSizeUnitsEnum.BYTE)
        return '{} {}'.format(result[0], result[1][2])
