Eolite: dialogue for replacing files during the copying

git-svn-id: svn://kolibrios.org@9471 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Serhii Sakhno 2021-12-25 22:43:50 +00:00
parent a143b06054
commit 19836de888
3 changed files with 86 additions and 12 deletions

View File

@ -22,6 +22,8 @@
#define T_MOVE_WINDOW_TITLE "<22>¥à¥¬¥é î..." #define T_MOVE_WINDOW_TITLE "<22>¥à¥¬¥é î..."
#define T_DELETE_WINDOW_TITLE "“¤ «ïî..." #define T_DELETE_WINDOW_TITLE "“¤ «ïî..."
#define T_ABORT_WINDOW_BUTTON "<22>à¥à¢ âì" #define T_ABORT_WINDOW_BUTTON "<22>à¥à¢ âì"
#define T_REPLACE_WINDOW_BUTTON "‡ ¬¥­¨âì"
#define T_SKIP_WINDOW_BUTTON "<22>யãáâ¨âì"
#define T_SELECT_APP_TO_OPEN_WITH "‚ë¡¥à¨â¥ ¯à®£à ¬¬ã ¤«ï ®âªàëâ¨ï ä ©« " #define T_SELECT_APP_TO_OPEN_WITH "‚ë¡¥à¨â¥ ¯à®£à ¬¬ã ¤«ï ®âªàëâ¨ï ä ©« "
#define DEL_MORE_FILES_1 "¢ë¡à ­­ë¥ í«¥¬¥­âë (" #define DEL_MORE_FILES_1 "¢ë¡à ­­ë¥ í«¥¬¥­âë ("
#define DEL_MORE_FILES_2 " èâ.)?" #define DEL_MORE_FILES_2 " èâ.)?"
@ -117,6 +119,8 @@ char *actions[] = {
#define T_MOVE_WINDOW_TITLE "Moving..." #define T_MOVE_WINDOW_TITLE "Moving..."
#define T_DELETE_WINDOW_TITLE "Deleting..." #define T_DELETE_WINDOW_TITLE "Deleting..."
#define T_ABORT_WINDOW_BUTTON "Abort" #define T_ABORT_WINDOW_BUTTON "Abort"
#define T_REPLACE_WINDOW_BUTTON "Replace"
#define T_SKIP_WINDOW_BUTTON "Skip"
#define T_SELECT_APP_TO_OPEN_WITH "Select application to open file" #define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
#define DEL_MORE_FILES_1 "selected items(" #define DEL_MORE_FILES_1 "selected items("
#define DEL_MORE_FILES_2 " pcs.)?" #define DEL_MORE_FILES_2 " pcs.)?"

View File

@ -19,6 +19,7 @@ enum {
void DisplayOperationForm(int operation_flag) void DisplayOperationForm(int operation_flag)
{ {
dword title; dword title;
dword id;
if (operation_flag==COPY_FLAG) { if (operation_flag==COPY_FLAG) {
title = T_COPY_WINDOW_TITLE; title = T_COPY_WINDOW_TITLE;
copy_bar.progress_color = 0x00FF00; copy_bar.progress_color = 0x00FF00;
@ -41,16 +42,36 @@ void DisplayOperationForm(int operation_flag)
switch(CheckEvent()) switch(CheckEvent())
{ {
case evButton: case evButton:
DialogExit(); id = GetButtonID();
switch(id)
{
case 2:
DialogExit();
break;
case 3:
copy_state = FILE_REPLACE;
break;
case 4:
copy_state = FILE_SKIP;
break;
}
break; break;
case evReDraw: case evReDraw:
DefineAndDrawWindow(Form.left+Form.width-200, Form.top+90, WIN_DIALOG_W+9, DefineAndDrawWindow(Form.left+Form.width-200, Form.top+90, WIN_DIALOG_W+9,
skin_height+WIN_DIALOG_H, 0x34, sc.work, title, 0); skin_height+WIN_DIALOG_H+70, 0x34, sc.work, title, 0);
GetProcessInfo(#Dialog_Form, SelfInfo); GetProcessInfo(#Dialog_Form, SelfInfo);
DrawCaptButton(WIN_DIALOG_W-PR_LEFT-101, PR_TOP+PR_H+6, 100,26, 2, DrawCaptButton(WIN_DIALOG_W-PR_LEFT-101, PR_TOP+PR_H+6, 100,26, 2,
sc.button, sc.button_text, T_ABORT_WINDOW_BUTTON); sc.button, sc.button_text, T_ABORT_WINDOW_BUTTON);
if (copy_state == FILE_EXISTS)
{
WriteText(WIN_DIALOG_W-PR_LEFT-301, PR_TOP+PR_H+46, 0x90, sc.work_text, "File exists!!");
DrawCaptButton(WIN_DIALOG_W-PR_LEFT-301, PR_TOP+PR_H+76, 100,26, 3,
sc.button, sc.button_text, T_REPLACE_WINDOW_BUTTON);
DrawCaptButton(WIN_DIALOG_W-PR_LEFT-101, PR_TOP+PR_H+76, 100,26, 4,
sc.button, sc.button_text, T_SKIP_WINDOW_BUTTON);
}
DrawRectangle3D(PR_LEFT-1, PR_TOP-1, PR_W+1, PR_H+1, sc.work_dark, sc.work_light); DrawRectangle3D(PR_LEFT-1, PR_TOP-1, PR_W+1, PR_H+1, sc.work_dark, sc.work_light);
} }
} }
@ -71,7 +92,10 @@ void Operation_Draw_Progress(dword filename) {
WriteText(PR_LEFT, PR_TOP-20, 0x90, sc.work_text, filename); WriteText(PR_LEFT, PR_TOP-20, 0x90, sc.work_text, filename);
progressbar_draw stdcall (#copy_bar); progressbar_draw stdcall (#copy_bar);
progressbar_progress stdcall (#copy_bar); if (copy_state == FILE_DEFAULT)
{
progressbar_progress stdcall (#copy_bar);
}
WriteTextWithBg(PR_LEFT, PR_TOP+PR_H+5, 0xD0, sc.work_text, WriteTextWithBg(PR_LEFT, PR_TOP+PR_H+5, 0xD0, sc.work_text,
sprintf(#param, "%i/%i", copy_bar.value, copy_bar.max), sc.work); sprintf(#param, "%i/%i", copy_bar.value, copy_bar.max), sc.work);

View File

@ -7,10 +7,20 @@
#include "../lib/fs.h" #include "../lib/fs.h"
#endif #endif
enum {
FILE_DEFAULT=0,
FILE_EXISTS,
FILE_REPLACE,
FILE_SKIP,
};
int copy_state = FILE_DEFAULT;
:int copyf(dword from1, in1) :int copyf(dword from1, in1)
{ {
dword error; dword error;
BDVK CopyFile_atr1; BDVK CopyFile_atr1;
copy_state = FILE_DEFAULT;
if (!from1) || (!in1) if (!from1) || (!in1)
{ {
@ -26,8 +36,22 @@
return CopyFolder(from1, in1); return CopyFolder(from1, in1);
else else
{ {
Operation_Draw_Progress(from1+strrchr(from1, '/')); while(1)
return CopyFile(from1, in1); {
Operation_Draw_Progress(from1+strrchr(from1, '/'));
if (copy_state == FILE_DEFAULT) || (copy_state == FILE_REPLACE)
{
error = CopyFile(from1, in1);
if (error != 222)
{
return error;
}
}
if (copy_state == FILE_SKIP)
{
return 0;
}
}
} }
} }
@ -42,6 +66,11 @@
} }
else else
{ {
if (file_exists(copy_in3)) && (copy_state != FILE_REPLACE)
{
copy_state = FILE_EXISTS;
return 222;
}
if (GetFreeRAM()-1024*1024 < CopyFile_atr.sizelo) //GetFreeRam-1Mb and convert to bytes if (GetFreeRAM()-1024*1024 < CopyFile_atr.sizelo) //GetFreeRam-1Mb and convert to bytes
{ {
if (error = CopyFileByBlocks(CopyFile_atr.sizelo, copy_from3, copy_in3)) if (error = CopyFileByBlocks(CopyFile_atr.sizelo, copy_from3, copy_in3))
@ -79,6 +108,7 @@
for (i=0; i<fcount; i++) for (i=0; i<fcount; i++)
{ {
copy_state = FILE_DEFAULT;
filename = i*304+dirbuf+72; filename = i*304+dirbuf+72;
sprintf(#copy_from2,"%s/%s",from2,filename); sprintf(#copy_from2,"%s/%s",from2,filename);
sprintf(#copy_in2,"%s/%s",in2,filename); sprintf(#copy_in2,"%s/%s",in2,filename);
@ -90,11 +120,27 @@
} }
else else
{ {
Operation_Draw_Progress(filename+strrchr(filename, '/')); while(1)
if (error=CopyFile(#copy_from2, #copy_in2))
{ {
if (fabs(error)==8) { debugln("Stop copying."); break;} //TODO: may be need grobal var like stop_all Operation_Draw_Progress(filename+strrchr(filename, '/'));
error=CopyFile(#copy_from2, #copy_in2); // #2 :) if (copy_state == FILE_DEFAULT) || (copy_state == FILE_REPLACE)
{
error = CopyFile(#copy_from2, #copy_in2);
if (error != 222)
{
if (error)
{
if (fabs(error)==8) { debugln("Stop copying."); break;} //TODO: may be need grobal var like stop_all
error=CopyFile(#copy_from2, #copy_in2); // #2 :)
}
break;
}
}
if (copy_state == FILE_SKIP)
{
copy_state = FILE_DEFAULT;
break;
}
} }
} }
} }