Timeline: Maybe be more accurate in reporting used disk space.

This commit is contained in:
Jonathan Moore Liles 2012-03-04 03:50:16 -08:00
parent 4f472c2a8e
commit ae6b78cf89
2 changed files with 18 additions and 11 deletions

View File

@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/vfs.h>
unsigned long
modification_time ( const char *file )
@ -182,25 +183,25 @@ read_line ( const char *dir, const char *name, char **value )
#include <sys/statvfs.h>
/** return the number of blocks free on filesystem containing file named /file/ */
unsigned long
fsblkcnt_t
free_space ( const char *file )
{
struct statvfs st;
struct statfs st;
memset( &st, 0, sizeof( st ) );
statvfs( file, &st );
statfs( file, &st );
return st.f_bfree;
return st.f_bavail;
}
/** return the total number of blocks on filesystem containing file named /file/ */
unsigned long
fsblkcnt_t
total_space ( const char *file )
{
struct statvfs st;
struct statfs st;
memset( &st, 0, sizeof( st ) );
statvfs( file, &st );
statfs( file, &st );
return st.f_blocks;
}
@ -209,7 +210,10 @@ total_space ( const char *file )
int
percent_used ( const char *file )
{
const size_t ts = total_space( file );
const double ts = total_space( file );
const double fs = free_space( file );
return 100 - ( ts ? free_space( file ) * 100 / ts : 0 );
double percent_free = ( ( fs / ts ) * 100.0f );
return (int) (100.0f - percent_free);
}

View File

@ -717,7 +717,7 @@ ab.run();}
private xywh {921 41 104 14} labelsize 10
}
Fl_Box {} {
label {disk:}
label {filesystem}
xywh {810 27 55 18} labelsize 10 align 16
}
Fl_Progress disk_usage_progress {
@ -838,7 +838,10 @@ update_progress( capture_buffer_progress, cbp, timeline->total_input_buffer_perc
update_progress( playback_buffer_progress, pbp, timeline->total_output_buffer_percent() );
update_progress( cpu_load_progress, clp, engine ? engine->cpu_load() : 0 );
update_progress( disk_usage_progress, dup, percent_used( "." ) );
if ( Project::open() )
update_progress( disk_usage_progress, dup, percent_used( Project::path() ) );
else
update_progress( disk_usage_progress, dup, 0 );
if ( timeline->total_capture_xruns() )
capture_buffer_progress->selection_color( FL_RED );