mirror of
https://gittea.dev/nova/th.git
synced 2025-10-21 10:20:15 -04:00
sum the size of the current dir
This commit is contained in:
28
threading.c
28
threading.c
@@ -277,6 +277,16 @@ void *thread_btm(){
|
||||
|
||||
char size_index = -1;
|
||||
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
unsigned long i;
|
||||
unsigned long total_dir_size = 0;
|
||||
for(i = 0; i < mid_file_count; i++) {
|
||||
if (!(mid_content[i].file_type & (FILE_TYPE_DIR | FILE_TYPE_SYMLINK))) {
|
||||
total_dir_size += mid_content[i].file_size;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
do {
|
||||
parsed_number=disk_size_free;
|
||||
disk_size_free /= 1024;
|
||||
@@ -286,9 +296,25 @@ void *thread_btm(){
|
||||
|
||||
snprintf(float_str, 10, "%0.2lf", parsed_number);
|
||||
|
||||
memcpy(btm_buffer + (offset_back - strlen(float_str) - 1), float_str, strlen(float_str));
|
||||
btm_buffer[offset_back - 2] = size_unit[(unsigned)size_index];
|
||||
offset_back -= strlen(float_str) + 2;
|
||||
memcpy(btm_buffer + offset_back, float_str, strlen(float_str));
|
||||
|
||||
parsed_number = 0;
|
||||
size_index = -1;
|
||||
do {
|
||||
parsed_number=total_dir_size;
|
||||
total_dir_size /= 1024;
|
||||
size_index++;
|
||||
} while (total_dir_size > 1 && size_index < size_unit_count);
|
||||
|
||||
offset_back -= strlen(ui_btm_current_dir_size) + 5;
|
||||
memcpy(btm_buffer + offset_back, ui_btm_current_dir_size, strlen(ui_btm_current_dir_size));
|
||||
|
||||
snprintf(float_str, 10, "%0.2lf", parsed_number);
|
||||
btm_buffer[offset_back - 2] = size_unit[(unsigned)size_index];
|
||||
offset_back -= strlen(float_str) + 2;
|
||||
memcpy(btm_buffer + offset_back, float_str, strlen(float_str));
|
||||
|
||||
pthread_mutex_unlock(&mutex_btm);
|
||||
}
|
||||
|
Reference in New Issue
Block a user