From fd19f06ec5a2b3ae0e644a1e1c2d406440f71a57 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sat, 15 Sep 2018 10:48:42 +0000 Subject: [PATCH] Eolite 3.92: remove duplicated functions, move global variables to local SysMon 0.85: get tmp disk sizes, code refactoring git-svn-id: svn://kolibrios.org@7369 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/eolite/Eolite.c | 1 - programs/cmm/eolite/include/copy.h | 14 +- programs/cmm/eolite/include/delete.h | 22 ++- programs/cmm/eolite/include/fs.h | 34 ----- programs/cmm/eolite/include/properties.h | 72 +++------- programs/cmm/eolite/include/translations.h | 4 +- programs/cmm/lib/fs.h | 105 ++++++++++++--- programs/cmm/lib/obj/libini.h | 10 +- programs/cmm/sysmon/sysmon.c | 149 ++++++++------------- 9 files changed, 195 insertions(+), 216 deletions(-) delete mode 100644 programs/cmm/eolite/include/fs.h diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 3fe204706a..4144643943 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -117,7 +117,6 @@ edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x100000 PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0}; byte cmd_free=0; #include "include\translations.h" -#include "include\fs.h" #include "include\settings.h" #include "include\progress_dialog.h" diff --git a/programs/cmm/eolite/include/copy.h b/programs/cmm/eolite/include/copy.h index c72ee49891..20776eaa36 100644 --- a/programs/cmm/eolite/include/copy.h +++ b/programs/cmm/eolite/include/copy.h @@ -78,7 +78,10 @@ void PasteThread() int paste_elements_count = 0; dword buf; dword path_offset; - file_count_copy = 0; + dword file_count_paste = 0; + _dir_size paste_dir_size; + BDVK file_info_count; + copy_bar.value = 0; buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1); @@ -88,11 +91,14 @@ void PasteThread() //calculate copy files count for progress bar for (j = 0; j < paste_elements_count; j++) { GetFileInfo(path_offset, #file_info_count); - if ( file_info_count.isfolder ) DirFileCount(path_offset); - else file_count_copy++; + if ( file_info_count.isfolder ) { + paste_dir_size.get(path_offset); + file_count_paste += paste_dir_size.files; + } + else file_count_paste++; path_offset += strlen(path_offset) + 1; } - copy_bar.max = file_count_copy; + copy_bar.max = file_count_paste; if (cut_active) operation_flag = MOVE_FLAG; else operation_flag = COPY_FLAG; diff --git a/programs/cmm/eolite/include/delete.h b/programs/cmm/eolite/include/delete.h index 9663ac43d3..d606992651 100644 --- a/programs/cmm/eolite/include/delete.h +++ b/programs/cmm/eolite/include/delete.h @@ -30,8 +30,10 @@ void Del_File_Thread() { byte del_from[4096]; int tst, count, i; - - file_count_copy = 0; + + BDVK file_info_count; + _dir_size delete_dir_size; + dword file_count_delete = 0; copy_bar.value = 0; operation_flag = DELETE_FLAG; @@ -42,18 +44,24 @@ void Del_File_Thread() if (getElementSelectedFlag(i) == true) { sprintf(#del_from,"%s/%s",#path,file_mas[i]*304+buf+72); GetFileInfo(#del_from, #file_info_count); - if ( file_info_count.isfolder ) DirFileCount(#del_from); - else file_count_copy++; + if ( file_info_count.isfolder ) { + delete_dir_size.get(#del_from); + file_count_delete += delete_dir_size.files; + } + else file_count_delete++; } } } else { - if (itdir) DirFileCount(#file_path); - else file_count_copy++; + if (itdir) { + delete_dir_size.get(#file_path); + file_count_delete += delete_dir_size.files; + } + else file_count_delete++; } - copy_bar.max = file_count_copy; + copy_bar.max = file_count_delete; del_error = 0; DisplayOperationForm(); diff --git a/programs/cmm/eolite/include/fs.h b/programs/cmm/eolite/include/fs.h deleted file mode 100644 index 6f2c806576..0000000000 --- a/programs/cmm/eolite/include/fs.h +++ /dev/null @@ -1,34 +0,0 @@ -BDVK file_info_count; -int file_count_copy; - -void DirFileCount(dword way) -{ - dword dirbuf, fcount, i, filename; - dword cur_file; - if (dir_exists(way)) - { - cur_file = malloc(4096); - // In the process of recursive descent, memory must be allocated - // dynamically, because the static variable cause a fault!!! - // But unfortunately pass away to sacrifice speed. - GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL); - filename = dirbuf+72; - for (i=0; i was a bug !!! But unfortunately pass away to sacrifice speed. - GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL); - for (i=0; i"); - sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count); + sprintf(#folder_info,"%s%d%s%d",SET_6,more_files_count.files,SET_7,more_files_count.folders); WriteText(file_name_ed.left+4, 30, 0x90, system.color.work_text, #folder_info); - sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(size_dir, NULL),size_dir,SET_BYTE_LANG); + sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(more_files_count.bytes, NULL),more_files_count.bytes,SET_BYTE_LANG); WriteText(120, 97, 0x90, system.color.work_text, #element_size_label); } else @@ -348,9 +312,9 @@ void DrawPropertiesWindow() else { WriteText(10,116, 0x90, system.color.work_text, PR_T_CONTAINS); - sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count); + sprintf(#folder_info,"%s%d%s%d",SET_6,dir_size.files,SET_7,dir_size.folders); WriteText(120, 116, 0x90, system.color.work_text, #folder_info); - element_size = size_dir; + element_size = dir_size.bytes; } WriteTextLines(10, 136, 0x90, system.color.work_text, CREATED_OPENED_MODIFIED, 20); DrawDate(120, 136, system.color.work_text, #file_info_general.datecreate); diff --git a/programs/cmm/eolite/include/translations.h b/programs/cmm/eolite/include/translations.h index d40d28bace..80cbc71928 100644 --- a/programs/cmm/eolite/include/translations.h +++ b/programs/cmm/eolite/include/translations.h @@ -1,5 +1,5 @@ -#define TITLE "Eolite File Manager v3.91" -#define ABOUT_TITLE "EOLITE 3.91" +#define TITLE "Eolite File Manager v3.92" +#define ABOUT_TITLE "EOLITE 3.92" #ifdef LANG_RUS ?define T_FILE "” ©«" diff --git a/programs/cmm/lib/fs.h b/programs/cmm/lib/fs.h index 540daeea56..e8a0120d2b 100644 --- a/programs/cmm/lib/fs.h +++ b/programs/cmm/lib/fs.h @@ -6,6 +6,12 @@ #include "../lib/date.h" #endif +//===================================================// +// // +// Basic System Functions // +// // +//===================================================// + :struct f70{ dword func; dword param1; @@ -156,7 +162,6 @@ $int 0x40 } - :f70 read_dir_70; :int ReadDir(dword file_count, read_buffer, dir_path) { @@ -172,6 +177,12 @@ $int 0x40 } +//===================================================// +// // +// Misc // +// // +//===================================================// + :bool dir_exists(dword fpath) { char buf[32]; @@ -180,7 +191,6 @@ } /* - // This implementation of dir_exists() is faster than // previous but here virtual folders like // '/' and '/tmp' are not recognised as FOLDERS @@ -194,7 +204,6 @@ } */ - :bool file_exists(dword fpath) { BDVK ReadFile_atr; @@ -202,7 +211,6 @@ return false; } - enum { DIRS_ALL, @@ -269,6 +277,23 @@ enum return ini_path; } +:dword notify(dword notify_param) +{ + return RunProgram("/sys/@notify", notify_param); +} + +:void die(dword _last_msg) +{ + notify(_last_msg); + ExitProcess(); +} + +//===================================================// +// // +// Convert Size // +// // +//===================================================// + :byte ConvertSize_size_prefix[8]; :dword ConvertSize(dword bytes) { @@ -292,18 +317,7 @@ enum else return ConvertSize(bytes_lo); } -:dword notify(dword notify_param) -{ - return RunProgram("/sys/@notify", notify_param); -} - -:void die(dword _last_msg) -{ - notify(_last_msg); - ExitProcess(); -} - -:unsigned char size[25]=0; +:unsigned char size[25]; :dword ConvertSizeToKb(unsigned int bytes) { unsigned int kb; @@ -324,6 +338,12 @@ enum return #size; } +//===================================================// +// // +// Copy // +// // +//===================================================// + :int CopyFileAtOnce(dword size, copyFrom, copyTo) dword cbuf; int error; @@ -379,5 +399,58 @@ int block_size=1024*1024*4; //copy by 4 MiB return error; } +//===================================================// +// // +// Directory Size // +// // +//===================================================// + +:struct _dir_size +{ + BDVK dir_info; + dword folders; + dword files; + dword bytes; + void get(); + void calculate_loop(); +} dir_size; + +:void _dir_size::get(dword way) +{ + folders = files = bytes = 0; + if (way) calculate_loop(way); +} + +:void _dir_size::calculate_loop(dword way) +{ + dword dirbuf, fcount, i, filename; + dword cur_file; + if (dir_exists(way)) + { + cur_file = malloc(4096); + // In the process of recursive descent, memory must be allocated dynamically, + // because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed. + GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL); + for (i=0; i was a bug !!! But unfortunately pass away to sacrifice speed. - GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL); - for (i=0; i