Subversion Repositories Kolibri OS

Rev

Rev 5459 | 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) {
4428 leency 64
	#define WIN_W 300
65
	#define WIN_H 50
4076 leency 66
	DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_W,GetSkinHeight()+WIN_H-1,0x34,sc.work,T_PASTE_WINDOW);
67
	WriteText(5,8, 0x80, sc.work_text, T_PASTE_WINDOW_TEXT);
68
	DrawBar(5, 26, WIN_W-10, 10, sc.work);
69
	WriteText(5,26, 0x80, sc.work_text, filename);
4042 leency 70
	if (CheckEvent()==evButton)
71
	{
72
		notify(T_CANCEL_PASTE);
4861 leency 73
		CopyExit();
4042 leency 74
	}
75
}
76
 
77
void Paste()
78
{
79
	char copy_rezult;
4428 leency 80
	byte copy_from[4096];
5174 punk_joker 81
	int j;
5209 punk_joker 82
    int cnt = 0;
4864 punk_joker 83
	dword buf;
4042 leency 84
 
4864 punk_joker 85
	buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
5209 punk_joker 86
    if (DSDWORD[buf+4] != 3) return;
5174 punk_joker 87
	cnt = ESINT[buf+8];
5209 punk_joker 88
    for (j = 0; j < cnt; j++) {
5174 punk_joker 89
		strlcpy(#copy_from, j*4096+buf+10, 4096);
4861 leency 90
		if (!copy_from) CopyExit();
4042 leency 91
		strcpy(#copy_to, #path);
92
		strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
4698 punk_joker 93
		if (!strcmp(#copy_from,#copy_to))
94
		{
95
			strcpy(#copy_to, #path);
96
			strcat(#copy_to, "new_");
97
			strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
98
		}
99
		if (strstr(#copy_to, #copy_from))
100
		{
101
			notify("Copy directory into itself is a bad idea...");
4861 leency 102
			CopyExit();
4698 punk_joker 103
		}
104
		if (copy_rezult = copyf(#copy_from,#copy_to))
105
		{
106
			Write_Error(copy_rezult);
107
		}
4894 punk_joker 108
 
109
		else if (cut_active)
110
		{
111
			strcpy(#file_path, #copy_from);
112
			Del_File(true);
113
 
114
		}
4042 leency 115
	}
4894 punk_joker 116
	if (cut_active)
4042 leency 117
	{
118
		cut_active=false;
119
	}
5459 punk_joker 120
	if (info_after_copy) notify(INFO_AFTER_COPY);
4861 leency 121
	CopyExit();
122
}
123
 
124
void CopyExit()
125
{
126
	action_buf = COPY_PASTE_END;
4042 leency 127
	ActivateWindow(GetProcessSlot(Form.ID));
128
	ExitProcess();
4861 leency 129
}