fix some error

This commit is contained in:
chatlanin 2023-04-19 21:08:44 +03:00
parent cf2b28beca
commit dea68d7b33

View File

@ -11,19 +11,26 @@ void print_in_color(const T& text, const std::string& color)
} }
template <typename T> template <typename T>
std::string get_size_string(const T& size) { std::string get_size_string(const T& size)
if (size < 1024) { {
if (size < 1024)
{
return std::to_string(size) + " B"; return std::to_string(size) + " B";
} else if (size < 1024 * 1024) { }
else if (size < 1024 * 1024)
{
return std::to_string(size / 1024) + " KB"; return std::to_string(size / 1024) + " KB";
} else if (size < 1024 * 1024 * 1024) { }
else if (size < 1024 * 1024 * 1024)
{
return std::to_string(size / 1024 / 1024) + " MB"; return std::to_string(size / 1024 / 1024) + " MB";
} else { }
else
{
return std::to_string(size / 1024 / 1024 / 1024) + " GB"; return std::to_string(size / 1024 / 1024 / 1024) + " GB";
} }
} }
auto main() -> int auto main() -> int
{ {
std::ifstream fs("/etc/mtab"); std::ifstream fs("/etc/mtab");
@ -39,8 +46,8 @@ auto main() -> int
continue; continue;
} }
unsigned long long total_size = (unsigned long long) stat.f_frsize * stat.f_blocks; unsigned long long total_size = (unsigned long long)stat.f_frsize * stat.f_blocks;
unsigned long long free_size = (unsigned long long) stat.f_frsize * stat.f_bfree; unsigned long long free_size = (unsigned long long)stat.f_frsize * stat.f_bfree;
unsigned long long used_size = total_size - free_size; unsigned long long used_size = total_size - free_size;
std::cout << "Точка монтирования: " << mount_entry->mnt_dir << "\n"; std::cout << "Точка монтирования: " << mount_entry->mnt_dir << "\n";