Subversion Repositories Kolibri OS

Rev

Rev 5481 | 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
{
5174 punk_joker 20
        dword selected_offset2;
21
        byte copy_t[4096];
22
        int cont = 0;
23
        dword buff_data;
24
        int ind = 0;
25
 
26
        for (i=0; i
27
        {
28
                selected_offset2 = file_mas[i]*304 + buf+32 + 7;
29
                if (ESBYTE[selected_offset2]) cont++;
30
        }
5209 punk_joker 31
		if (!cont)
32
		{
33
            buff_data = malloc(4106);
34
            ESDWORD[buff_data] = 4106;
35
            ESDWORD[buff_data+4] = 3;
36
            ESINT[buff_data+8] = 1;
37
            strlcpy(buff_data+10, #file_path, 4096);;
38
			clipboard.SetSlotData(4106, buff_data);
39
	    }
40
		else
41
		{
42
            buff_data = malloc(cont*4096+10);
43
            ESDWORD[buff_data] = cont*4096+10;
44
            ESDWORD[buff_data+4] = 3;
45
            ESINT[buff_data+8] = cont;
46
            for (i=0; i
47
            {
48
                    selected_offset2 = file_mas[i]*304 + buf+32 + 7;
49
                    if (ESBYTE[selected_offset2]) {
50
                            strcpy(#copy_t, #path);
51
                            strcat(#copy_t, file_mas[i]*304+buf+72);
52
 
53
                            strlcpy(ind*4096+buff_data+10, #copy_t, 4096);;
54
                            ind++;
55
                    }
56
            }
57
			clipboard.SetSlotData(cont*4096+10, buff_data);
58
		}
4042 leency 59
	cut_active = cut;
5209 punk_joker 60
	free(buff_data);
4042 leency 61
}
62
 
63
void copyf_Draw_Progress(dword filename) {
5512 punk_joker 64
	DrawRectangle(0,0,WIN_COPY_W-5, 15,sc.work);
4076 leency 65
	WriteText(5,8, 0x80, sc.work_text, T_PASTE_WINDOW_TEXT);
5512 punk_joker 66
	DrawBar(5, 26, WIN_COPY_W-10, 10, sc.work);
4076 leency 67
	WriteText(5,26, 0x80, sc.work_text, filename);
4042 leency 68
}
69
 
70
void Paste()
71
{
72
	char copy_rezult;
4428 leency 73
	byte copy_from[4096];
5174 punk_joker 74
	int j;
5209 punk_joker 75
    int cnt = 0;
4864 punk_joker 76
	dword buf;
4042 leency 77
 
4864 punk_joker 78
	buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
5209 punk_joker 79
    if (DSDWORD[buf+4] != 3) return;
5174 punk_joker 80
	cnt = ESINT[buf+8];
5209 punk_joker 81
    for (j = 0; j < cnt; j++) {
5174 punk_joker 82
		strlcpy(#copy_from, j*4096+buf+10, 4096);
4861 leency 83
		if (!copy_from) CopyExit();
4042 leency 84
		strcpy(#copy_to, #path);
85
		strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
4698 punk_joker 86
		if (!strcmp(#copy_from,#copy_to))
87
		{
88
			strcpy(#copy_to, #path);
89
			strcat(#copy_to, "new_");
90
			strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
91
		}
92
		if (strstr(#copy_to, #copy_from))
93
		{
94
			notify("Copy directory into itself is a bad idea...");
4861 leency 95
			CopyExit();
4698 punk_joker 96
		}
97
		if (copy_rezult = copyf(#copy_from,#copy_to))
98
		{
99
			Write_Error(copy_rezult);
100
		}
4894 punk_joker 101
 
102
		else if (cut_active)
103
		{
104
			strcpy(#file_path, #copy_from);
105
			Del_File(true);
106
 
107
		}
4042 leency 108
	}
4894 punk_joker 109
	if (cut_active)
4042 leency 110
	{
111
		cut_active=false;
112
	}
5459 punk_joker 113
	if (info_after_copy) notify(INFO_AFTER_COPY);
4861 leency 114
	CopyExit();
115
}
116
 
117
void CopyExit()
118
{
119
	action_buf = COPY_PASTE_END;
4042 leency 120
	ActivateWindow(GetProcessSlot(Form.ID));
121
	ExitProcess();
4861 leency 122
}