Rev 8944 | Rev 8952 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8944 | Rev 8949 | ||
---|---|---|---|
1 | //===================================================// |
1 | //===================================================// |
2 | // // |
2 | // // |
3 | // MASS ACTIONS // |
3 | // MASS ACTIONS // |
4 | // // |
4 | // // |
5 | //===================================================// |
5 | //===================================================// |
6 | 6 | ||
7 | void setElementSelectedFlag(dword n, int state) { |
7 | void setElementSelectedFlag(dword n, int state) { |
8 | dword selected_offset = items.get(n)*304 + buf+32 + 7; |
8 | dword selected_offset = items.get(n)*304 + buf+32 + 7; |
9 | ESBYTE[selected_offset] = state; |
9 | ESBYTE[selected_offset] = state; |
10 | if (n==0) && (strncmp(items.get(n)*304+buf+72,"..",2)==0) { |
10 | if (n==0) && (strncmp(items.get(n)*304+buf+72,"..",2)==0) { |
11 | ESBYTE[selected_offset] = false; //do not selec ".." directory |
11 | ESBYTE[selected_offset] = false; //do not selec ".." directory |
12 | return; |
12 | return; |
13 | } |
13 | } |
14 | if (state==true) selected_count++; |
14 | if (state==true) selected_count++; |
15 | if (state==false) selected_count--; |
15 | if (state==false) selected_count--; |
16 | if (selected_count<0) selected_count=0; |
16 | if (selected_count<0) selected_count=0; |
17 | } |
17 | } |
18 | 18 | ||
19 | int getElementSelectedFlag(dword n) { |
19 | int getElementSelectedFlag(dword n) { |
20 | dword selected_offset = items.get(n)*304 + buf+32 + 7; |
20 | dword selected_offset = items.get(n)*304 + buf+32 + 7; |
21 | return ESBYTE[selected_offset]; |
21 | return ESBYTE[selected_offset]; |
22 | } |
22 | } |
23 | 23 | ||
24 | dword GetFilesCount(dword _in_path) |
24 | dword GetFilesCount(dword _in_path) |
25 | { |
25 | { |
26 | BDVK file_info_count; |
26 | BDVK file_info_count; |
27 | DIR_SIZE paste_dir_size; |
27 | DIR_SIZE paste_dir_size; |
28 | 28 | ||
29 | GetFileInfo(_in_path, #file_info_count); |
29 | GetFileInfo(_in_path, #file_info_count); |
30 | if ( file_info_count.isfolder ) { |
30 | if ( file_info_count.isfolder ) { |
31 | return paste_dir_size.get(_in_path); |
31 | return paste_dir_size.get(_in_path); |
32 | } else { |
32 | } else { |
33 | return 1; |
33 | return 1; |
34 | } |
34 | } |
35 | } |
35 | } |
36 | 36 | ||
37 | //===================================================// |
37 | //===================================================// |
38 | // // |
38 | // // |
39 | // COPY AND PASTE // |
39 | // COPY AND PASTE // |
40 | // // |
40 | // // |
41 | //===================================================// |
41 | //===================================================// |
42 | byte copy_to[4096]; |
42 | byte copy_to[4096]; |
43 | byte copy_from[4096]; |
43 | byte copy_from[4096]; |
44 | bool cut_active = false; |
44 | bool cut_active = false; |
45 | 45 | ||
46 | enum {COPY, CUT, DELETE}; |
46 | enum {COPY, CUT, DELETE}; |
47 | 47 | ||
48 | void CopyFilesListToClipboard(bool _cut_active) |
48 | void CopyFilesListToClipboard(bool _cut_active) |
49 | { |
49 | { |
50 | byte copy_t[4096]; |
50 | byte copy_t[4096]; |
51 | dword buff_data; |
51 | dword buff_data; |
52 | dword path_len = 0; |
52 | dword path_len = 0; |
53 | dword size_buf = 0; |
53 | dword size_buf = 0; |
54 | dword copy_buf_offset = 0; |
54 | dword copy_buf_offset = 0; |
55 | dword i; |
55 | dword i; |
56 | 56 | ||
57 | if (files.count<=0) return; //no files |
57 | if (files.count<=0) return; //no files |
58 | 58 | ||
59 | if (_cut_active!=DELETE) cut_active = _cut_active; |
59 | if (_cut_active!=DELETE) cut_active = _cut_active; |
60 | 60 | ||
61 | //if no element selected by "Insert" key, then we copy current element |
61 | //if no element selected by "Insert" key, then we copy current element |
62 | if (!selected_count) { |
62 | if (!selected_count) { |
63 | setElementSelectedFlag(files.cur_y, true); |
63 | setElementSelectedFlag(files.cur_y, true); |
64 | } |
64 | } |
65 | 65 | ||
66 | if (!selected_count) return; |
66 | if (!selected_count) return; |
67 | 67 | ||
68 | size_buf = 10; |
68 | size_buf = 10; |
69 | for (i=0; i |
69 | for (i=0; i |
70 | { |
70 | { |
71 | if (getElementSelectedFlag(i) == true) { |
71 | if (getElementSelectedFlag(i) == true) { |
72 | sprintf(#copy_t,"%s/%s",#path,items.get(i)*304+buf+72); |
72 | sprintf(#copy_t,"%s/%s",path,items.get(i)*304+buf+72); |
73 | path_len = strlen(#copy_t); |
73 | path_len = strlen(#copy_t); |
74 | size_buf += path_len + 1; |
74 | size_buf += path_len + 1; |
75 | } |
75 | } |
76 | } |
76 | } |
77 | buff_data = malloc(size_buf); |
77 | buff_data = malloc(size_buf); |
78 | ESDWORD[buff_data] = size_buf; |
78 | ESDWORD[buff_data] = size_buf; |
79 | ESDWORD[buff_data+4] = SLOT_DATA_TYPE_RAW; |
79 | ESDWORD[buff_data+4] = SLOT_DATA_TYPE_RAW; |
80 | ESINT[buff_data+8] = selected_count; |
80 | ESINT[buff_data+8] = selected_count; |
81 | copy_buf_offset = buff_data + 10; |
81 | copy_buf_offset = buff_data + 10; |
82 | for (i=0; i |
82 | for (i=0; i |
83 | { |
83 | { |
84 | if (getElementSelectedFlag(i) == true) { |
84 | if (getElementSelectedFlag(i) == true) { |
85 | sprintf(copy_buf_offset,"%s/%s",#path,items.get(i)*304+buf+72); |
85 | sprintf(copy_buf_offset,"%s/%s",path,items.get(i)*304+buf+72); |
86 | copy_buf_offset += strlen(copy_buf_offset) + 1; |
86 | copy_buf_offset += strlen(copy_buf_offset) + 1; |
87 | 87 | ||
88 | if (cut_active) { |
88 | if (cut_active) { |
89 | if (i>=files.first) && (i |
89 | if (i>=files.first) && (i |
90 | PutShadow(files.x+4,i-files.first*files.item_h+files.y,icons16_default.w,files.item_h,1,-3); |
90 | PutShadow(files.x+4,i-files.first*files.item_h+files.y,icons16_default.w,files.item_h,1,-3); |
91 | } |
91 | } |
92 | } |
92 | } |
93 | } |
93 | } |
94 | if (cut_active) { |
94 | if (cut_active) { |
95 | pause(20); |
95 | pause(20); |
96 | List_ReDraw(); |
96 | List_ReDraw(); |
97 | } |
97 | } |
98 | if (selected_count==1) setElementSelectedFlag(files.cur_y, false); |
98 | if (selected_count==1) setElementSelectedFlag(files.cur_y, false); |
99 | Clipboard__SetSlotData(size_buf, buff_data); |
99 | Clipboard__SetSlotData(size_buf, buff_data); |
100 | free(buff_data); |
100 | free(buff_data); |
101 | } |
101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void PasteThread() |
104 | void PasteThread() |
105 | { |
105 | { |
106 | char copy_rezult; |
106 | char copy_rezult; |
107 | int j, i, slash_count=0; |
107 | int j, i, slash_count=0; |
108 | int paste_elements_count = 0; |
108 | int paste_elements_count = 0; |
109 | dword buf; |
109 | dword buf; |
110 | dword path_offset; |
110 | dword path_offset; |
111 | 111 | ||
112 | buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1); |
112 | buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1); |
113 | if (DSDWORD[buf+4] != 3) return; |
113 | if (DSDWORD[buf+4] != 3) return; |
114 | paste_elements_count = ESINT[buf+8]; |
114 | paste_elements_count = ESINT[buf+8]; |
115 | path_offset = buf + 10; |
115 | path_offset = buf + 10; |
116 | 116 | ||
117 | if (cut_active) { |
117 | if (cut_active) { |
118 | DisplayOperationForm(MOVE_FLAG); |
118 | DisplayOperationForm(MOVE_FLAG); |
119 | } else { |
119 | } else { |
120 | DisplayOperationForm(COPY_FLAG); |
120 | DisplayOperationForm(COPY_FLAG); |
121 | } |
121 | } |
122 | 122 | ||
123 | if (cut_active) { |
123 | if (cut_active) { |
124 | for (j = 0; j < paste_elements_count; j++) { |
124 | for (j = 0; j < paste_elements_count; j++) { |
125 | sprintf(#copy_to, "%s/%s", #path, path_offset+strrchr(path_offset,'/')); |
125 | sprintf(#copy_to, "%s/%s", path, path_offset+strrchr(path_offset,'/')); |
126 | slash_count = 0; |
126 | slash_count = 0; |
127 | for (i=0; i<=10; i++) { |
127 | for (i=0; i<=10; i++) { |
128 | if (copy_to[i]=='/') slash_count++; |
128 | if (copy_to[i]=='/') slash_count++; |
129 | if (slash_count==3) break; |
129 | if (slash_count==3) break; |
130 | } |
130 | } |
131 | if (strncmp(#copy_to, path_offset, i)!=0) goto _DIFFERENT_DRIVES; |
131 | if (strncmp(#copy_to, path_offset, i)!=0) goto _DIFFERENT_DRIVES; |
132 | RenameMove(#copy_to+i, path_offset); |
132 | RenameMove(#copy_to+i, path_offset); |
133 | if (EAX!=0) goto _DIFFERENT_DRIVES; |
133 | if (EAX!=0) goto _DIFFERENT_DRIVES; |
134 | path_offset += strlen(path_offset) + 1; |
134 | path_offset += strlen(path_offset) + 1; |
135 | } |
135 | } |
136 | DialogExit(); |
136 | DialogExit(); |
137 | } |
137 | } |
138 | 138 | ||
139 | _DIFFERENT_DRIVES: |
139 | _DIFFERENT_DRIVES: |
140 | path_offset = buf + 10; |
140 | path_offset = buf + 10; |
141 | for (j = 0; j < paste_elements_count; j++) { |
141 | for (j = 0; j < paste_elements_count; j++) { |
142 | copy_bar.max += GetFilesCount(path_offset); |
142 | copy_bar.max += GetFilesCount(path_offset); |
143 | path_offset += strlen(path_offset) + 1; |
143 | path_offset += strlen(path_offset) + 1; |
144 | } |
144 | } |
145 | 145 | ||
146 | path_offset = buf + 10; |
146 | path_offset = buf + 10; |
147 | for (j = 0; j < paste_elements_count; j++) { |
147 | for (j = 0; j < paste_elements_count; j++) { |
148 | strcpy(#copy_from, path_offset); |
148 | strcpy(#copy_from, path_offset); |
149 | if (!copy_from) DialogExit(); |
149 | if (!copy_from) DialogExit(); |
150 | sprintf(#copy_to, "%s/%s", #path, #copy_from+strrchr(#copy_from,'/')); |
150 | sprintf(#copy_to, "%s/%s", path, #copy_from+strrchr(#copy_from,'/')); |
151 | if (streq(#copy_from,#copy_to)) |
151 | if (streq(#copy_from,#copy_to)) |
152 | { |
152 | { |
153 | if (cut_active) continue; |
153 | if (cut_active) continue; |
154 | sprintf(#copy_to, "%s/NEW_%s", #path, #copy_from+strrchr(#copy_from,'/')); |
154 | sprintf(#copy_to, "%s/NEW_%s", path, #copy_from+strrchr(#copy_from,'/')); |
155 | } |
155 | } |
156 | if (strstr(#copy_to, #copy_from)) |
156 | if (strstr(#copy_to, #copy_from)) |
157 | { |
157 | { |
158 | notify("'Not possible to copy directory into itself.\nProcess terminated.' -E"); |
158 | notify("'Not possible to copy directory into itself.\nProcess terminated.' -E"); |
159 | DialogExit(); |
159 | DialogExit(); |
160 | } |
160 | } |
161 | 161 | ||
162 | if (copy_rezult = copyf(#copy_from,#copy_to)) |
162 | if (copy_rezult = copyf(#copy_from,#copy_to)) |
163 | { |
163 | { |
164 | Write_Error(copy_rezult); |
164 | Write_Error(copy_rezult); |
165 | if (copy_rezult==8) DialogExit(); //not enough space |
165 | if (copy_rezult==8) DialogExit(); //not enough space |
166 | } |
166 | } |
167 | else if (cut_active) |
167 | else if (cut_active) |
168 | { |
168 | { |
169 | strcpy(#file_path, #copy_from); |
169 | strcpy(#file_path, #copy_from); |
170 | RecursiveDelete(#copy_from, false); |
170 | RecursiveDelete(#copy_from, false); |
171 | 171 | ||
172 | } |
172 | } |
173 | path_offset += strlen(path_offset) + 1; |
173 | path_offset += strlen(path_offset) + 1; |
174 | } |
174 | } |
175 | DialogExit(); |
175 | DialogExit(); |
176 | } |
176 | } |
177 | 177 | ||
178 | 178 | ||
179 | //===================================================// |
179 | //===================================================// |
180 | // // |
180 | // // |
181 | // DELETE // |
181 | // DELETE // |
182 | // // |
182 | // // |
183 | //===================================================// |
183 | //===================================================// |
184 | 184 | ||
185 | int del_error; |
185 | int del_error; |
186 | int RecursiveDelete(dword way, bool show_progress) |
186 | int RecursiveDelete(dword way, bool show_progress) |
187 | { |
187 | { |
188 | dword dirbuf, fcount, i, filename; |
188 | dword dirbuf, fcount, i, filename; |
189 | int error; |
189 | int error; |
190 | char del_from[4096]; |
190 | char del_from[4096]; |
191 | if (dir_exists(way)) |
191 | if (dir_exists(way)) |
192 | { |
192 | { |
193 | if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error; |
193 | if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error; |
194 | for (i=0; i |
194 | for (i=0; i |
195 | { |
195 | { |
196 | //if (CheckEvent()==evReDraw) draw_window(); |
196 | //if (CheckEvent()==evReDraw) draw_window(); |
197 | filename = i*304+dirbuf+72; |
197 | filename = i*304+dirbuf+72; |
198 | sprintf(#del_from,"%s/%s",way,filename); |
198 | sprintf(#del_from,"%s/%s",way,filename); |
199 | if ( ESDWORD[filename-40] & ATR_FOLDER ) { |
199 | if ( ESDWORD[filename-40] & ATR_FOLDER ) { |
200 | RecursiveDelete(#del_from, true); |
200 | RecursiveDelete(#del_from, true); |
201 | } else { |
201 | } else { |
202 | if (show_progress) Operation_Draw_Progress(filename); |
202 | if (show_progress) Operation_Draw_Progress(filename); |
203 | if (error = DeleteFile(#del_from)) del_error = error; |
203 | if (error = DeleteFile(#del_from)) del_error = error; |
204 | } |
204 | } |
205 | } |
205 | } |
206 | } |
206 | } |
207 | if (error = DeleteFile(way)) del_error = error; |
207 | if (error = DeleteFile(way)) del_error = error; |
208 | } |
208 | } |
209 | 209 | ||
210 | void DeleteThread() |
210 | void DeleteThread() |
211 | { |
211 | { |
212 | int j; |
212 | int j; |
213 | int elements_count = 0; |
213 | int elements_count = 0; |
214 | dword buf; |
214 | dword buf; |
215 | dword path_offset; |
215 | dword path_offset; |
216 | 216 | ||
217 | DisplayOperationForm(DELETE_FLAG); |
217 | DisplayOperationForm(DELETE_FLAG); |
218 | 218 | ||
219 | buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1); |
219 | buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1); |
220 | Clipboard__DeleteLastSlot(); |
220 | Clipboard__DeleteLastSlot(); |
221 | if (DSDWORD[buf+4] != 3) return; |
221 | if (DSDWORD[buf+4] != 3) return; |
222 | elements_count = ESINT[buf+8]; |
222 | elements_count = ESINT[buf+8]; |
223 | 223 | ||
224 | path_offset = buf + 10; |
224 | path_offset = buf + 10; |
225 | for (j = 0; j < elements_count; j++) { |
225 | for (j = 0; j < elements_count; j++) { |
226 | copy_bar.max += GetFilesCount(path_offset); |
226 | copy_bar.max += GetFilesCount(path_offset); |
227 | path_offset += strlen(path_offset) + 1; |
227 | path_offset += strlen(path_offset) + 1; |
228 | } |
228 | } |
229 | 229 | ||
230 | path_offset = buf + 10; |
230 | path_offset = buf + 10; |
231 | for (j = 0; j < elements_count; j++) { |
231 | for (j = 0; j < elements_count; j++) { |
232 | RecursiveDelete(path_offset, true); |
232 | RecursiveDelete(path_offset, true); |
233 | path_offset += strlen(path_offset) + 1; |
233 | path_offset += strlen(path_offset) + 1; |
234 | } |
234 | } |
235 | if (del_error) Write_Error(del_error); |
235 | if (del_error) Write_Error(del_error); |
236 | DialogExit(); |
236 | DialogExit(); |
237 | }>>>>=10;>> |
237 | }>>>>=10;>> |
238 | >=0)>0)> |
238 | >=0)>0)> |