2014-01-07 02:04:38 +01:00
|
|
|
//Leency 2008-2014
|
2013-04-04 19:07:38 +02:00
|
|
|
|
2014-01-07 02:04:38 +01:00
|
|
|
byte copy_to[4096];
|
|
|
|
byte cut_active=0;
|
2014-03-26 13:51:42 +01:00
|
|
|
byte id_add_to_copy=0;
|
|
|
|
byte add_to_copy_active=0;
|
2013-10-15 01:16:04 +02:00
|
|
|
enum {NOCUT, CUT, COPY_PASTE_END};
|
2014-01-06 01:36:08 +01:00
|
|
|
|
2014-03-26 13:51:42 +01:00
|
|
|
struct path_str {
|
|
|
|
char Item[4096];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_HISTORY_NUM 10
|
|
|
|
|
2014-01-06 01:36:08 +01:00
|
|
|
Clipboard clipboard;
|
|
|
|
|
2014-03-26 13:51:42 +01:00
|
|
|
struct Copy_Path {
|
|
|
|
dword size;
|
|
|
|
dword type;
|
2014-04-21 05:01:45 +02:00
|
|
|
int count;
|
2014-03-26 13:51:42 +01:00
|
|
|
path_str copy_list[MAX_HISTORY_NUM];
|
|
|
|
};
|
|
|
|
|
|
|
|
Copy_Path copy_path;
|
|
|
|
|
|
|
|
void add_to_copy(dword pcth)
|
|
|
|
{
|
|
|
|
strlcpy(#copy_path.copy_list[id_add_to_copy].Item, pcth);
|
2014-04-21 05:01:45 +02:00
|
|
|
if (add_to_copy_active == 1)
|
|
|
|
{
|
|
|
|
id_add_to_copy++;
|
|
|
|
copy_path.count = id_add_to_copy;
|
|
|
|
}
|
|
|
|
else copy_path.count = 1;
|
2014-03-26 13:51:42 +01:00
|
|
|
}
|
|
|
|
|
2013-04-04 19:07:38 +02:00
|
|
|
|
|
|
|
void Copy(dword pcth, char cut)
|
|
|
|
{
|
2014-04-21 05:01:45 +02:00
|
|
|
if (add_to_copy_active == 0) add_to_copy(pcth);
|
2014-03-26 13:51:42 +01:00
|
|
|
copy_path.type = 3;
|
|
|
|
copy_path.size = sizeof(copy_path);
|
|
|
|
clipboard.SetSlotData(sizeof(copy_path), #copy_path);
|
2013-04-04 19:07:38 +02:00
|
|
|
cut_active = cut;
|
|
|
|
}
|
|
|
|
|
2013-10-14 00:18:41 +02:00
|
|
|
void copyf_Draw_Progress(dword filename) {
|
2014-01-07 02:04:38 +01:00
|
|
|
#define WIN_W 300
|
|
|
|
#define WIN_H 50
|
2013-10-23 19:55:07 +02:00
|
|
|
DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_W,GetSkinHeight()+WIN_H-1,0x34,sc.work,T_PASTE_WINDOW);
|
|
|
|
WriteText(5,8, 0x80, sc.work_text, T_PASTE_WINDOW_TEXT);
|
|
|
|
DrawBar(5, 26, WIN_W-10, 10, sc.work);
|
|
|
|
WriteText(5,26, 0x80, sc.work_text, filename);
|
2013-10-14 00:18:41 +02:00
|
|
|
if (CheckEvent()==evButton)
|
|
|
|
{
|
|
|
|
notify(T_CANCEL_PASTE);
|
2014-04-20 11:52:52 +02:00
|
|
|
CopyExit();
|
2013-10-14 00:18:41 +02:00
|
|
|
}
|
2013-04-04 19:07:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Paste()
|
|
|
|
{
|
2013-10-15 01:16:04 +02:00
|
|
|
char copy_rezult;
|
2014-01-07 02:04:38 +01:00
|
|
|
byte copy_from[4096];
|
2014-04-21 05:01:45 +02:00
|
|
|
int tst, count;
|
|
|
|
dword buf;
|
|
|
|
|
|
|
|
buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
|
|
|
|
count = DSINT[buf+8];
|
|
|
|
debugi(count);
|
|
|
|
|
|
|
|
add_to_copy_active=0;
|
|
|
|
id_add_to_copy=0;
|
2013-04-04 19:07:38 +02:00
|
|
|
|
2014-04-21 05:01:45 +02:00
|
|
|
for (j = 0; j < count; j++) {
|
2014-03-26 13:51:42 +01:00
|
|
|
tst = j*4096;
|
2014-04-21 05:01:45 +02:00
|
|
|
strlcpy(#copy_from, buf+12+tst, 4096);
|
2014-03-26 13:51:42 +01:00
|
|
|
debug(#copy_from);
|
2014-04-20 11:52:52 +02:00
|
|
|
if (!copy_from) CopyExit();
|
2013-04-04 19:07:38 +02:00
|
|
|
strcpy(#copy_to, #path);
|
|
|
|
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
2014-03-26 13:51:42 +01:00
|
|
|
if (!strcmp(#copy_from,#copy_to))
|
|
|
|
{
|
|
|
|
strcpy(#copy_to, #path);
|
|
|
|
strcat(#copy_to, "new_");
|
|
|
|
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
|
|
|
}
|
|
|
|
if (strstr(#copy_to, #copy_from))
|
|
|
|
{
|
|
|
|
notify("Copy directory into itself is a bad idea...");
|
2014-04-20 11:52:52 +02:00
|
|
|
CopyExit();
|
2014-03-26 13:51:42 +01:00
|
|
|
}
|
|
|
|
if (copy_rezult = copyf(#copy_from,#copy_to))
|
|
|
|
{
|
|
|
|
Write_Error(copy_rezult);
|
|
|
|
}
|
2013-04-04 19:07:38 +02:00
|
|
|
}
|
2013-04-05 02:26:21 +02:00
|
|
|
if (copy_rezult = copyf(#copy_from,#copy_to))
|
2013-04-04 19:07:38 +02:00
|
|
|
{
|
|
|
|
Write_Error(copy_rezult);
|
|
|
|
}
|
2013-04-05 02:26:21 +02:00
|
|
|
else if (cut_active)
|
2013-04-04 19:07:38 +02:00
|
|
|
{
|
|
|
|
strcpy(#file_path, #copy_from);
|
|
|
|
Del_File(true);
|
|
|
|
cut_active=false;
|
|
|
|
}
|
2014-04-21 05:01:45 +02:00
|
|
|
for (j = 0; j < MAX_HISTORY_NUM; j++) strcpy(#copy_path.copy_list[j].Item[0], 0);
|
2014-04-20 11:52:52 +02:00
|
|
|
CopyExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyExit()
|
|
|
|
{
|
|
|
|
action_buf = COPY_PASTE_END;
|
2013-04-04 19:07:38 +02:00
|
|
|
ActivateWindow(GetProcessSlot(Form.ID));
|
|
|
|
ExitProcess();
|
2014-04-20 11:52:52 +02:00
|
|
|
}
|