def formatFileSize(size):
    """
    Format the given file size in bytes to human readable format.
    """
    if size < 1024:
        return '%iB' % size
    elif size < 1024 ** 2:
        return '%iK' % (size / 1024)
    elif size < 1024 ** 3:
        return '%iM' % (size / 1024 ** 2)
    else:
        return '%iG' % (size / 1024 ** 3)
