diff --git a/nonlib/file.C b/nonlib/file.C index f4abbd0..42fb8ea 100644 --- a/nonlib/file.C +++ b/nonlib/file.C @@ -24,6 +24,7 @@ #include #include #include +#include unsigned long modification_time ( const char *file ) @@ -182,25 +183,25 @@ read_line ( const char *dir, const char *name, char **value ) #include /** 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); } diff --git a/timeline/src/TLE.fl b/timeline/src/TLE.fl index d5024b9..ef21f76 100644 --- a/timeline/src/TLE.fl +++ b/timeline/src/TLE.fl @@ -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 );