gui2/tgame_cache_options: Handle negative values from filesystem::dir_size()

The Boost.filesystem version of this function yields a negative value of
-1 to signify a non-critical error. For some reason, utils::si_string()
formats this incorrectly and even yields an incorrect number, probably
due to some floating point math mess-up.

Kind of fixes bug #22261 by preventing a call to utils::si_string() with
a negative value, but that function really ought to be fixed separately
anyway.
This commit is contained in:
Ignacio R. Morelle 2014-12-23 05:53:58 -03:00
parent cd022369aa
commit b79df59e08

View file

@ -126,9 +126,13 @@ void tgame_cache_options::update_cache_size_display()
return; return;
} }
size_label_->set_label(utils::si_string(filesystem::dir_size(cache_path_), const int size = filesystem::dir_size(cache_path_);
true,
_("unit_byte^B"))); if(size < 0) {
size_label_->set_label(_("dir_size^Unknown"));
} else {
size_label_->set_label(utils::si_string(size, true, _("unit_byte^B")));
}
} }
void tgame_cache_options::copy_to_clipboard_callback() void tgame_cache_options::copy_to_clipboard_callback()