Subversion Repositories Kolibri OS

Rev

Rev 5694 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5694 Rev 5804
Line 1... Line 1...
1
byte copy_to[4096];
1
byte copy_to[4096];
2
byte copy_from[4096];
2
byte copy_from[4096];
3
byte cut_active=0;
3
byte cut_active=0;
Line 4... Line -...
4
 
-
 
5
progress_bar copy_bar = {0,16,49,50,20,0,0,1,0xFFFFFF,0x00FF00,0x000000};
-
 
6
 
4
 
Line 7... Line 5...
7
enum {NOCUT, CUT, COPY_PASTE_END};
5
enum {NOCUT, CUT};
Line 8... Line 6...
8
 
6
 
9
Clipboard clipboard;
7
Clipboard clipboard;
Line 50... Line 48...
50
	copy_stak = malloc(20000);
48
	copy_stak = malloc(20000);
51
	CreateThread(#PasteThread,copy_stak+20000-4);
49
	CreateThread(#PasteThread,copy_stak+20000-4);
52
}
50
}
53
 
51
 
Line 54... Line -...
54
BDVK file_info_count;
-
 
55
int file_count_copy;
-
 
56
 
-
 
57
void DirFileCount(dword way)
-
 
58
{
-
 
59
	dword dirbuf, fcount, i, filename;
-
 
60
	dword cur_file;
-
 
61
	if (isdir(way))
-
 
62
	{
-
 
63
		cur_file = malloc(4096);
-
 
64
		// In the process of recursive descent, memory must be allocated dynamically, because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
-
 
65
		GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
-
 
66
		for (i=0; i
-
 
67
		{
-
 
68
			filename = i*304+dirbuf+72;
-
 
69
			sprintf(cur_file,"%s/%s",way,filename);
-
 
70
			
-
 
71
			if (TestBit(ESDWORD[filename-40], 4) )
-
 
72
			{
-
 
73
				file_count_copy++;
-
 
74
				DirFileCount(cur_file);
-
 
75
			}
-
 
76
			else
-
 
77
			{
-
 
78
				file_count_copy++;
-
 
79
			}
-
 
80
		}
-
 
81
		free(cur_file);
-
 
82
	}
-
 
83
}
-
 
84
 
-
 
85
void PasteThread()
52
void PasteThread()
86
{
53
{
87
	char copy_rezult;
54
	char copy_rezult;
88
	int j;
55
	int j;
89
	int cnt = 0;
56
	int cnt = 0;
Line 100... Line 67...
100
		if ( file_info_count.isfolder ) DirFileCount(#copy_from);
67
		if ( file_info_count.isfolder ) DirFileCount(#copy_from);
101
		else file_count_copy++;
68
		else file_count_copy++;
102
	}
69
	}
103
	copy_bar.max = file_count_copy;
70
	copy_bar.max = file_count_copy;
104
	DisplayCopyfForm();
71
	
-
 
72
	if (cut_active)  operation_flag = MOVE_FLAG;
-
 
73
	else  operation_flag = COPY_FLAG;
-
 
74
	
-
 
75
	DisplayOperationForm();
105
	for (j = 0; j < cnt; j++) {
76
	for (j = 0; j < cnt; j++) {
106
		strlcpy(#copy_from, j*4096+buf+10, 4096);
77
		strlcpy(#copy_from, j*4096+buf+10, 4096);
107
		if (!copy_from) CopyExit();
78
		if (!copy_from) DialogExit();
108
		strcpy(#copy_to, #path);
79
		strcpy(#copy_to, #path);
109
		strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
80
		strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
110
		if (!strcmp(#copy_from,#copy_to))
81
		if (!strcmp(#copy_from,#copy_to))
111
		{
82
		{
112
			strcpy(#copy_to, #path);
83
			strcpy(#copy_to, #path);
113
			strcat(#copy_to, "new_");
84
			strcat(#copy_to, "new_");
Line 115... Line 86...
115
		}
86
		}
116
		if (strstr(#copy_to, #copy_from))
87
		if (strstr(#copy_to, #copy_from))
117
		{
88
		{
118
			notify("Copy directory into itself is a bad idea...");
89
			notify("Copy directory into itself is a bad idea...");
119
			CopyExit();
90
			DialogExit();
120
		}
91
		}
121
 
92
 
Line 122... Line 93...
122
		if (copy_rezult = copyf(#copy_from,#copy_to))
93
		if (copy_rezult = copyf(#copy_from,#copy_to))
123
		{
94
		{
124
			Write_Error(copy_rezult);
95
			Write_Error(copy_rezult);
125
		}
96
		}
126
		else if (cut_active)
97
		else if (cut_active)
127
		{
98
		{
128
			strcpy(#file_path, #copy_from);
99
			//strcpy(#file_path, #copy_from);
129
			Del_File(true);
100
			Del_File2(#copy_from, 0);
Line 130... Line 101...
130
			
101
			
131
		}
102
		}
132
	}
103
	}
133
	if (cut_active)
104
	if (cut_active)
134
	{
105
	{
135
		cut_active=false;
106
		cut_active=false;
136
	}
107
	}
137
	if (info_after_copy) notify(INFO_AFTER_COPY);
-
 
138
	CopyExit();
-
 
139
}
-
 
140
 
-
 
141
#define WIN_COPY_W 345
-
 
142
#define WIN_COPY_H 110
-
 
143
proc_info Copy_Form;
-
 
144
 
-
 
145
void DisplayCopyfForm()
-
 
146
{
-
 
147
	  switch(CheckEvent())
-
 
148
	  {
-
 
149
		 case evButton:
-
 
150
			notify(T_CANCEL_PASTE);
108
	if (info_after_copy) notify(INFO_AFTER_COPY);
151
			CopyExit();
-
 
152
			break;
-
 
153
		 
-
 
154
		case evReDraw:
-
 
155
			DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_COPY_W,GetSkinHeight()+WIN_COPY_H,0x34,0xFFFFFF,T_PASTE_WINDOW_TITLE);
-
 
156
			GetProcessInfo(#Copy_Form, SelfInfo);
-
 
157
			WriteText(45, 11, 0x80, system.color.work_text, T_PASTE_WINDOW_TEXT);
-
 
158
			DrawFlatButton(Copy_Form.cwidth - 96, Copy_Form.cheight - 32, 80, 22, 10, system.color.work_button, T_PASTE_WINDOW_BUTTON);
-
 
159
			DrawBar(8, 10, 32, 32, 0xFFFfff);
-
 
160
			break;
-
 
161
	  }
-
 
162
}
-
 
163
 
-
 
164
void CopyExit() {
-
 
165
	action_buf = COPY_PASTE_END;
-
 
166
	ActivateWindow(GetProcessSlot(Form.ID));
-
 
167
	ExitProcess();
-
 
168
}
-
 
169
 
-
 
170
 
-
 
171
void copyf_Draw_Progress(dword copying_filename) {
-
 
172
	if (Copy_Form.cwidth==0)
-
 
173
	{
-
 
174
		copy_bar.value++;
-
 
175
		return;
-
 
176
	}
-
 
177
	copy_bar.width = Copy_Form.cwidth-32;
-
 
178
	DisplayCopyfForm();
-
 
179
	Put_icon(copying_filename+strrchr(copying_filename,'.'), 16, 19, 0xFFFfff, 0);
-
 
180
	DrawBar(45, 29, Copy_Form.cwidth-45, 10, 0xFFFFFF);
-
 
181
	WriteText(45, 29, 0x80, 0x000000, copying_filename);
-
 
182
	progressbar_draw stdcall (#copy_bar);
-
 
183
	progressbar_progress stdcall (#copy_bar);
-
 
184
	//copy_bar.value++;
-
 
185
	//pause(10);
109
	DialogExit();
186
}
110
}