Eolite 3.2: deleting in another thread; progressbar while deleting

git-svn-id: svn://kolibrios.org@5804 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Serhii Sakhno 2015-09-05 17:50:37 +00:00
parent 1ed8c3d59c
commit 5d4d8a053c
5 changed files with 181 additions and 122 deletions

View File

@ -13,7 +13,6 @@
#include "..\lib\file_system.h"
#include "..\lib\gui.h"
#include "..\lib\list_box.h"
#include "..\lib\copyf.h"
#include "..\lib\random.h"
#include "..\lib\font.h"
//obj
@ -65,7 +64,7 @@ dword eolite_ini_path;
char scroll_used=false;
dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak;
dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak,delete_stak;
proc_info Form;
int mouse_dd, sc_slider_h, kolibrios_drive;
@ -88,7 +87,10 @@ PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp,
PathShow_data FileShow = {0, 56,215, 6, 100, 0, 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"
#include "..\lib\copyf.h"
#include "include\copy.h"
#include "include\gui.h"
#include "include\sorting.h"
@ -492,7 +494,7 @@ void main()
draw_window();
if (action_buf)
{
if (action_buf==COPY_PASTE_END)
if (action_buf==OPERATION_END)
{
FnProcess(5);
SelectFileByName(#copy_to+strrchr(#copy_to,'/'));
@ -800,10 +802,6 @@ void Del_Form()
byte f_count[128];
int dform_x = files.w - 220 / 2 + files.x;
if (!strncmp(#file_name,".",2)) || (!strncmp(#file_name,"..",2)) return;
if (del_active==2)
{
if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
}
else
{
if (!files.count) return;
@ -840,7 +838,7 @@ void Del_Form()
}
int del_error;
int Del_File2(dword way)
int Del_File2(dword way, sh_progr)
{
dword dirbuf, fcount, i, filename;
int error;
@ -855,10 +853,11 @@ int Del_File2(dword way)
sprintf(#del_from,"%s/%s",way,filename);
if ( TestBit(ESDWORD[filename-40], 4) )
{
Del_File2(#del_from);
Del_File2(#del_from, 1);
}
else
{
if (sh_progr) Operation_Draw_Progress(#del_from);
if (error = DeleteFile(#del_from)) del_error = error;
}
}
@ -866,18 +865,15 @@ int Del_File2(dword way)
if (error = DeleteFile(way)) del_error = error;
}
void Del_File(byte dodel)
void Del_File_Thread()
{
byte del_from[4096];
dword selected_offset2;
int tst, count, i;
if (dodel==true)
{
del_active=2;
if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
del_error = 0;
file_count_copy = 0;
copy_bar.value = 0;
operation_flag = DELETE_FLAG;
if (selected_count)
{
@ -886,22 +882,59 @@ void Del_File(byte dodel)
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
if (ESBYTE[selected_offset2]) {
sprintf(#del_from,"%s%s",#path,file_mas[i]*304+buf+72);
Del_File2(#del_from);
GetFileInfo(#del_from, #file_info_count);
if ( file_info_count.isfolder ) DirFileCount(#del_from);
else file_count_copy++;
}
}
}
else
{
Del_File2(#file_path);
if (itdir) DirFileCount(#file_path);
else file_count_copy++;
}
copy_bar.max = file_count_copy;
//if (dodel==true)
//{
//del_active=2;
//if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
del_error = 0;
DisplayOperationForm();
if (selected_count)
{
for (i=0; i<files.count; i++)
{
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
if (ESBYTE[selected_offset2]) {
sprintf(#del_from,"%s%s",#path,file_mas[i]*304+buf+72);
Del_File2(#del_from, 1);
}
}
}
else
{
Del_File2(#file_path, 1);
}
if (del_error) Write_Error(del_error);
}
del_active=0;
DeleteButton(301);
DeleteButton(302);
Open_Dir(#path,WITH_REDRAW);
DialogExit();
//}
//del_active=0;
//DeleteButton(301);
//DeleteButton(302);
//Open_Dir(#path,WITH_REDRAW);
}
void Del_File(byte dodel) {
del_active=0;
if (dodel)
{
delete_stak = malloc(20000);
CreateThread(#Del_File_Thread,delete_stak+20000-4);
}
else draw_window();
}
void SelectFileByName(dword that_file)
{

View File

@ -3,9 +3,7 @@ byte copy_to[4096];
byte copy_from[4096];
byte cut_active=0;
progress_bar copy_bar = {0,16,49,50,20,0,0,1,0xFFFFFF,0x00FF00,0x000000};
enum {NOCUT, CUT, COPY_PASTE_END};
enum {NOCUT, CUT};
Clipboard clipboard;
@ -52,37 +50,6 @@ void Paste() {
CreateThread(#PasteThread,copy_stak+20000-4);
}
BDVK file_info_count;
int file_count_copy;
void DirFileCount(dword way)
{
dword dirbuf, fcount, i, filename;
dword cur_file;
if (isdir(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<fcount; i++)
{
filename = i*304+dirbuf+72;
sprintf(cur_file,"%s/%s",way,filename);
if (TestBit(ESDWORD[filename-40], 4) )
{
file_count_copy++;
DirFileCount(cur_file);
}
else
{
file_count_copy++;
}
}
free(cur_file);
}
}
void PasteThread()
{
char copy_rezult;
@ -102,10 +69,14 @@ void PasteThread()
else file_count_copy++;
}
copy_bar.max = file_count_copy;
DisplayCopyfForm();
if (cut_active) operation_flag = MOVE_FLAG;
else operation_flag = COPY_FLAG;
DisplayOperationForm();
for (j = 0; j < cnt; j++) {
strlcpy(#copy_from, j*4096+buf+10, 4096);
if (!copy_from) CopyExit();
if (!copy_from) DialogExit();
strcpy(#copy_to, #path);
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
if (!strcmp(#copy_from,#copy_to))
@ -117,7 +88,7 @@ void PasteThread()
if (strstr(#copy_to, #copy_from))
{
notify("Copy directory into itself is a bad idea...");
CopyExit();
DialogExit();
}
if (copy_rezult = copyf(#copy_from,#copy_to))
@ -126,8 +97,8 @@ void PasteThread()
}
else if (cut_active)
{
strcpy(#file_path, #copy_from);
Del_File(true);
//strcpy(#file_path, #copy_from);
Del_File2(#copy_from, 0);
}
}
@ -136,52 +107,5 @@ void PasteThread()
cut_active=false;
}
if (info_after_copy) notify(INFO_AFTER_COPY);
CopyExit();
}
#define WIN_COPY_W 345
#define WIN_COPY_H 110
proc_info Copy_Form;
void DisplayCopyfForm()
{
switch(CheckEvent())
{
case evButton:
notify(T_CANCEL_PASTE);
CopyExit();
break;
case evReDraw:
DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_COPY_W,GetSkinHeight()+WIN_COPY_H,0x34,0xFFFFFF,T_PASTE_WINDOW_TITLE);
GetProcessInfo(#Copy_Form, SelfInfo);
WriteText(45, 11, 0x80, system.color.work_text, T_PASTE_WINDOW_TEXT);
DrawFlatButton(Copy_Form.cwidth - 96, Copy_Form.cheight - 32, 80, 22, 10, system.color.work_button, T_PASTE_WINDOW_BUTTON);
DrawBar(8, 10, 32, 32, 0xFFFfff);
break;
}
}
void CopyExit() {
action_buf = COPY_PASTE_END;
ActivateWindow(GetProcessSlot(Form.ID));
ExitProcess();
}
void copyf_Draw_Progress(dword copying_filename) {
if (Copy_Form.cwidth==0)
{
copy_bar.value++;
return;
}
copy_bar.width = Copy_Form.cwidth-32;
DisplayCopyfForm();
Put_icon(copying_filename+strrchr(copying_filename,'.'), 16, 19, 0xFFFfff, 0);
DrawBar(45, 29, Copy_Form.cwidth-45, 10, 0xFFFFFF);
WriteText(45, 29, 0x80, 0x000000, copying_filename);
progressbar_draw stdcall (#copy_bar);
progressbar_progress stdcall (#copy_bar);
//copy_bar.value++;
//pause(10);
DialogExit();
}

View File

@ -0,0 +1,31 @@
BDVK file_info_count;
int file_count_copy;
void DirFileCount(dword way)
{
dword dirbuf, fcount, i, filename;
dword cur_file;
if (isdir(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<fcount; i++)
{
filename = i*304+dirbuf+72;
sprintf(cur_file,"%s/%s",way,filename);
if (TestBit(ESDWORD[filename-40], 4) )
{
file_count_copy++;
DirFileCount(cur_file);
}
else
{
file_count_copy++;
}
}
free(cur_file);
}
}

View File

@ -0,0 +1,58 @@
#define WIN_DIALOG_W 345
#define WIN_DIALOG_H 110
proc_info Dialog_Form;
progress_bar copy_bar = {0,16,49,50,20,0,0,1,0xFFFFFF,0x00FF00,0x000000};
enum {COPY_FLAG, MOVE_FLAG, DELETE_FLAG, OPERATION_END};
int operation_flag;
void DisplayOperationForm()
{
switch(CheckEvent())
{
case evButton:
notify(T_CANCEL_PASTE);
DialogExit();
break;
case evReDraw:
if (operation_flag==COPY_FLAG) DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_DIALOG_W,GetSkinHeight()+WIN_DIALOG_H,0x34,0xFFFFFF,T_COPY_WINDOW_TITLE);
else if (operation_flag==MOVE_FLAG) DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_DIALOG_W,GetSkinHeight()+WIN_DIALOG_H,0x34,0xFFFFFF,T_MOVE_WINDOW_TITLE);
else DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_DIALOG_W,GetSkinHeight()+WIN_DIALOG_H,0x34,0xFFFFFF,T_DELETE_WINDOW_TITLE);
GetProcessInfo(#Dialog_Form, SelfInfo);
if (operation_flag==COPY_FLAG) WriteText(45, 11, 0x80, system.color.work_text, T_COPY_WINDOW_TEXT);
else if (operation_flag==MOVE_FLAG) WriteText(45, 11, 0x80, system.color.work_text, T_MOVE_WINDOW_TEXT);
else WriteText(45, 11, 0x80, system.color.work_text, T_DELETE_WINDOW_TEXT);
DrawFlatButton(Dialog_Form.cwidth - 96, Dialog_Form.cheight - 32, 80, 22, 10, system.color.work_button, T_ABORT_WINDOW_BUTTON);
DrawBar(8, 10, 32, 32, 0xFFFfff);
break;
}
}
void DialogExit() {
action_buf = OPERATION_END;
ActivateWindow(GetProcessSlot(Form.ID));
ExitProcess();
}
void Operation_Draw_Progress(dword copying_filename) {
if (Dialog_Form.cwidth==0)
{
copy_bar.value++;
return;
}
copy_bar.width = Dialog_Form.cwidth-32;
DisplayOperationForm();
Put_icon(copying_filename+strrchr(copying_filename,'.'), 16, 19, 0xFFFfff, 0);
DrawBar(45, 29, Dialog_Form.cwidth-45, 10, 0xFFFFFF);
WriteText(45, 29, 0x80, 0x000000, copying_filename);
progressbar_draw stdcall (#copy_bar);
progressbar_progress stdcall (#copy_bar);
//copy_bar.value++;
pause(50);
}

View File

@ -1,5 +1,5 @@
#define TITLE "Eolite File Manager v3.14"
#define ABOUT_TITLE "Eolite 3.14"
#define TITLE "Eolite File Manager v3.2"
#define ABOUT_TITLE "Eolite 3.2"
#ifdef LANG_RUS
?define T_FILE "” ©«"
@ -15,12 +15,17 @@
?define T_RENAME "<EFBFBD>¥à¥¨¬¥­®¢ âì"
?define FS_ITEM_ALREADY_EXISTS "'<27>«¥¬¥­â á â ª¨¬ ¨¬¥­¥¬ 㦥 áãé¥áâ¢ã¥â' -E"
?define T_DEL_ERROR_1 "Žè¨¡ª . <20> ¯ª  ­¥ ¯ãáâ ï."
?define WAIT_DELETING_FOLDER "“¤ «ï¥âáï ¯ ¯ª . <20>®¤®¦¨â¥..."
?define NOT_CREATE_FOLDER "<EFBFBD>¥ 㤠«®áì ᮧ¤ âì ¯ ¯ªã."
?define NOT_CREATE_FILE "<EFBFBD>¥ 㤠«®áì ᮧ¤ âì ä ©«."
?define T_PASTE_WINDOW_TITLE "Š®¯¨àãî..."
?define T_PASTE_WINDOW_TEXT "Š®¯¨àã¥âáï ä ©«:"
?define T_PASTE_WINDOW_BUTTON "<EFBFBD>à¥à¢ âì"
?define T_COPY_WINDOW_TITLE "Š®¯¨àãî..."
?define T_COPY_WINDOW_TEXT "Š®¯¨àã¥âáï ä ©«:"
?define T_MOVE_WINDOW_TITLE "<EFBFBD>¥à¥¬¥é î..."
?define T_MOVE_WINDOW_TEXT "<EFBFBD>¥à¥¬¥é ¥âáï ä ©«:"
?define T_DELETE_WINDOW_TITLE "“¤ «ïî..."
?define T_DELETE_WINDOW_TEXT "“¤ «ï¥âáï ä ©«:"
?define T_ABORT_WINDOW_BUTTON "<EFBFBD>à¥à¢ âì"
?define INFO_AFTER_COPY "Š®¯¨à®¢ ­¨¥ § ¢¥à襭®"
?define T_CANCEL_PASTE "Š®¯¨à®¢ ­¨¥ ¯à¥ªà é¥­®. <20> ¯ª  ᪮¯¨à®¢ ­  ­¥ ¯®«­®áâìî."
?define T_SELECT_APP_TO_OPEN_WITH "‚ë¡¥à¨â¥ ¯à®£à ¬¬ã ¤«ï ®âªàëâ¨ï ä ©« "
@ -43,9 +48,13 @@
?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
?define NOT_CREATE_FOLDER "Kataloogi ei saa luua."
?define NOT_CREATE_FILE "Faili ei saa luua."
?define T_PASTE_WINDOW_TITLE "Kopeerin..."
?define T_PASTE_WINDOW_TEXT "Kopeerin faili:"
?define T_PASTE_WINDOW_BUTTON "Abort"
?define T_COPY_WINDOW_TITLE "Copying..."
?define T_COPY_WINDOW_TEXT "Copying file:"
?define T_MOVE_WINDOW_TITLE "Moving..."
?define T_MOVE_WINDOW_TEXT "Moving file:"
?define T_DELETE_WINDOW_TITLE "Deleting..."
?define T_DELETE_WINDOW_TEXT "Deleting file:"
?define T_ABORT_WINDOW_BUTTON "Abort"
?define INFO_AFTER_COPY "Copy finished"
?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
@ -68,9 +77,13 @@
?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
?define NOT_CREATE_FOLDER "Folder can not be created."
?define NOT_CREATE_FILE "File can not be created."
?define T_PASTE_WINDOW_TITLE "Copying..."
?define T_PASTE_WINDOW_TEXT "Copying file:"
?define T_PASTE_WINDOW_BUTTON "Abort"
?define T_COPY_WINDOW_TITLE "Copying..."
?define T_COPY_WINDOW_TEXT "Copying file:"
?define T_MOVE_WINDOW_TITLE "Moving..."
?define T_MOVE_WINDOW_TEXT "Moving file:"
?define T_DELETE_WINDOW_TITLE "Deleting..."
?define T_DELETE_WINDOW_TEXT "Deleting file:"
?define T_ABORT_WINDOW_BUTTON "Abort"
?define INFO_AFTER_COPY "Copy finished"
?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"