mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
- CMovieBrowser::info_hdd_level(): fix miscalculation
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -1547,23 +1547,27 @@ void CMovieBrowser::info_hdd_level(bool paint_hdd)
|
|||||||
if (show_mode == MB_SHOW_YT)
|
if (show_mode == MB_SHOW_YT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int percent_used = 0;
|
||||||
|
int tmp_percent_used = 0;
|
||||||
struct statfs s;
|
struct statfs s;
|
||||||
long blocks_percent_used =0;
|
|
||||||
static long tmp_blocks_percent_used = 0;
|
|
||||||
if (getSelectedFile() != NULL) {
|
if (getSelectedFile() != NULL) {
|
||||||
if (::statfs(getSelectedFile()->Name.c_str(), &s) == 0) {
|
if (::statfs(getSelectedFile()->Name.c_str(), &s) == 0) {
|
||||||
long blocks_used = s.f_blocks - s.f_bfree;
|
if (s.f_blocks > 0) {
|
||||||
blocks_percent_used = (blocks_used * 1000 / (blocks_used + s.f_bavail) + 5)/10;
|
uint64_t bytes_total = s.f_blocks * s.f_bsize;
|
||||||
|
uint64_t bytes_free = s.f_bfree * s.f_bsize;
|
||||||
|
uint64_t bytes_used = bytes_total - bytes_free;
|
||||||
|
percent_used = (bytes_used * 200 + bytes_total) / 2 / bytes_total;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp_blocks_percent_used != blocks_percent_used || paint_hdd) {
|
if (tmp_percent_used != percent_used || paint_hdd) {
|
||||||
tmp_blocks_percent_used = blocks_percent_used;
|
tmp_percent_used = percent_used;
|
||||||
const short pbw = 100;
|
const short pbw = 100;
|
||||||
const short border = m_cBoxFrameTitleRel.iHeight/4;
|
const short border = m_cBoxFrameTitleRel.iHeight/4;
|
||||||
CProgressBar pb(m_cBoxFrame.iX+ m_cBoxFrameFootRel.iWidth - m_header->getContextBtnObject()->getWidth() - pbw - border, m_cBoxFrame.iY+m_cBoxFrameTitleRel.iY + border, pbw, m_cBoxFrameTitleRel.iHeight/2);
|
CProgressBar pb(m_cBoxFrame.iX+ m_cBoxFrameFootRel.iWidth - m_header->getContextBtnObject()->getWidth() - pbw - border, m_cBoxFrame.iY+m_cBoxFrameTitleRel.iY + border, pbw, m_cBoxFrameTitleRel.iHeight/2);
|
||||||
pb.setType(CProgressBar::PB_REDRIGHT);
|
pb.setType(CProgressBar::PB_REDRIGHT);
|
||||||
pb.setValues(blocks_percent_used, 100);
|
pb.setValues(percent_used, 100);
|
||||||
pb.paint(false);
|
pb.paint(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user