Subversion Repositories Kolibri OS

Rev

Rev 5512 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4428 leency 1
//Leency 2008-2014
4042 leency 2
 
5459 punk_joker 3
#ifdef LANG_RUS
4
	?define INFO_AFTER_COPY "Копирование завершено"
5
#elif LANG_EST
6
	?define INFO_AFTER_COPY "Copy finished"
7
#else
8
	?define INFO_AFTER_COPY "Copy finished"
9
#endif
10
 
4428 leency 11
byte copy_to[4096];
12
byte cut_active=0;
4896 punk_joker 13
 
4042 leency 14
enum {NOCUT, CUT, COPY_PASTE_END};
4427 punk_joker 15
 
16
Clipboard clipboard;
17
 
4896 punk_joker 18
void Copy(dword pcth, char cut)
4698 punk_joker 19
{
5513 punk_joker 20
    dword selected_offset2;
21
    byte copy_t[4096];
22
    dword buff_data;
23
    int ind = 0;
24
 
25
    if (selected_count)
26
	{
27
        buff_data = malloc(selected_count*4096+10);
28
        ESDWORD[buff_data] = selected_count*4096+10;
29
        ESDWORD[buff_data+4] = 3;
30
        ESINT[buff_data+8] = selected_count;
5174 punk_joker 31
        for (i=0; i
32
        {
5513 punk_joker 33
            selected_offset2 = file_mas[i]*304 + buf+32 + 7;
34
            if (ESBYTE[selected_offset2]) {
35
                strcpy(#copy_t, #path);
36
                strcat(#copy_t, file_mas[i]*304+buf+72);
37
                strlcpy(ind*4096+buff_data+10, #copy_t, 4096);;
38
                ind++;
39
            }
5174 punk_joker 40
        }
5513 punk_joker 41
		clipboard.SetSlotData(selected_count*4096+10, buff_data);
42
	}
43
	else
44
	{
45
		buff_data = malloc(4106);
46
        ESDWORD[buff_data] = 4106;
47
        ESDWORD[buff_data+4] = 3;
48
        ESINT[buff_data+8] = 1;
49
        strlcpy(buff_data+10, #file_path, 4096);;
50
		clipboard.SetSlotData(4106, buff_data);
51
	}
4042 leency 52
	cut_active = cut;
5209 punk_joker 53
	free(buff_data);
4042 leency 54
}
55
 
56
void copyf_Draw_Progress(dword filename) {
5512 punk_joker 57
	DrawRectangle(0,0,WIN_COPY_W-5, 15,sc.work);
4076 leency 58
	WriteText(5,8, 0x80, sc.work_text, T_PASTE_WINDOW_TEXT);
5512 punk_joker 59
	DrawBar(5, 26, WIN_COPY_W-10, 10, sc.work);
4076 leency 60
	WriteText(5,26, 0x80, sc.work_text, filename);
4042 leency 61
}
62
 
63
void Paste()
64
{
65
	char copy_rezult;
4428 leency 66
	byte copy_from[4096];
5174 punk_joker 67
	int j;
5209 punk_joker 68
    int cnt = 0;
4864 punk_joker 69
	dword buf;
4042 leency 70
 
4864 punk_joker 71
	buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
5209 punk_joker 72
    if (DSDWORD[buf+4] != 3) return;
5174 punk_joker 73
	cnt = ESINT[buf+8];
5209 punk_joker 74
    for (j = 0; j < cnt; j++) {
5174 punk_joker 75
		strlcpy(#copy_from, j*4096+buf+10, 4096);
4861 leency 76
		if (!copy_from) CopyExit();
4042 leency 77
		strcpy(#copy_to, #path);
78
		strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
4698 punk_joker 79
		if (!strcmp(#copy_from,#copy_to))
80
		{
81
			strcpy(#copy_to, #path);
82
			strcat(#copy_to, "new_");
83
			strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
84
		}
85
		if (strstr(#copy_to, #copy_from))
86
		{
87
			notify("Copy directory into itself is a bad idea...");
4861 leency 88
			CopyExit();
4698 punk_joker 89
		}
90
		if (copy_rezult = copyf(#copy_from,#copy_to))
91
		{
92
			Write_Error(copy_rezult);
93
		}
4894 punk_joker 94
 
95
		else if (cut_active)
96
		{
97
			strcpy(#file_path, #copy_from);
98
			Del_File(true);
99
 
100
		}
4042 leency 101
	}
4894 punk_joker 102
	if (cut_active)
4042 leency 103
	{
104
		cut_active=false;
105
	}
5459 punk_joker 106
	if (info_after_copy) notify(INFO_AFTER_COPY);
4861 leency 107
	CopyExit();
108
}
109
 
110
void CopyExit()
111
{
112
	action_buf = COPY_PASTE_END;
4042 leency 113
	ActivateWindow(GetProcessSlot(Form.ID));
114
	ExitProcess();
4861 leency 115
}