Browse Source

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

tags/non-daw-v1.2.0
Jonathan Moore Liles 13 years ago
parent
commit
ae6b78cf89
2 changed files with 18 additions and 11 deletions
  1. +13
    -9
      nonlib/file.C
  2. +5
    -2
      timeline/src/TLE.fl

+ 13
- 9
nonlib/file.C 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 );

double percent_free = ( ( fs / ts ) * 100.0f );

return 100 - ( ts ? free_space( file ) * 100 / ts : 0 );
return (int) (100.0f - percent_free);
}

+ 5
- 2
timeline/src/TLE.fl 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 );


Loading…
Cancel
Save