2015-02-24 13:48:22 +01:00
|
|
|
|
2014-01-07 02:04:38 +01:00
|
|
|
byte copy_to[4096];
|
2015-03-09 19:49:34 +01:00
|
|
|
byte copy_from[4096];
|
2014-01-07 02:04:38 +01:00
|
|
|
byte cut_active=0;
|
2014-01-06 01:36:08 +01:00
|
|
|
|
2015-09-05 19:50:37 +02:00
|
|
|
enum {NOCUT, CUT};
|
2014-03-26 13:51:42 +01:00
|
|
|
|
2016-11-01 13:14:17 +01:00
|
|
|
void setElementSelectedFlag(dword n, int state) {
|
2016-10-17 03:31:59 +02:00
|
|
|
dword selected_offset = file_mas[n]*304 + buf+32 + 7;
|
|
|
|
ESBYTE[selected_offset] = state;
|
2018-05-13 18:06:20 +02:00
|
|
|
if (n==0) && (strncmp(file_mas[n]*304+buf+72,"..",2)==0) {
|
|
|
|
ESBYTE[selected_offset] = false; //do not selec ".." directory
|
|
|
|
return;
|
|
|
|
}
|
2016-10-17 03:31:59 +02:00
|
|
|
if (state==true) selected_count++;
|
|
|
|
if (state==false) selected_count--;
|
2015-07-23 14:23:52 +02:00
|
|
|
}
|
|
|
|
|
2016-11-01 13:14:17 +01:00
|
|
|
int getElementSelectedFlag(dword n) {
|
|
|
|
dword selected_offset = file_mas[n]*304 + buf+32 + 7;
|
|
|
|
return ESBYTE[selected_offset];
|
|
|
|
}
|
|
|
|
|
2016-10-17 03:31:59 +02:00
|
|
|
void Copy(dword pcth, char cut)
|
2013-04-04 19:07:38 +02:00
|
|
|
{
|
2016-10-17 03:31:59 +02:00
|
|
|
byte copy_t[4096];
|
|
|
|
dword buff_data;
|
2016-10-15 23:39:03 +02:00
|
|
|
dword path_len = 0;
|
2016-10-17 03:31:59 +02:00
|
|
|
dword size_buf = 0;
|
|
|
|
dword copy_buf_offset = 0;
|
2018-10-01 18:41:14 +02:00
|
|
|
dword i;
|
2016-10-15 23:39:03 +02:00
|
|
|
|
2016-10-17 03:31:59 +02:00
|
|
|
if (files.count<=0) return; //no files
|
2018-05-13 18:06:20 +02:00
|
|
|
|
|
|
|
//if no element selected by "Insert" key, then we copy current element
|
|
|
|
if (!selected_count)
|
|
|
|
setElementSelectedFlag(files.cur_y, true);
|
|
|
|
|
|
|
|
if (!selected_count) return;
|
|
|
|
|
2016-10-17 03:31:59 +02:00
|
|
|
size_buf = 4;
|
|
|
|
for (i=0; i<files.count; i++)
|
2016-10-15 23:39:03 +02:00
|
|
|
{
|
2016-11-01 13:14:17 +01:00
|
|
|
if (getElementSelectedFlag(i) == true) {
|
2016-10-30 20:17:46 +01:00
|
|
|
sprintf(#copy_t,"%s/%s",#path,file_mas[i]*304+buf+72);
|
2016-10-17 03:31:59 +02:00
|
|
|
path_len = strlen(#copy_t);
|
|
|
|
size_buf += path_len + 1;
|
|
|
|
}
|
2016-10-15 23:39:03 +02:00
|
|
|
}
|
2016-10-17 03:31:59 +02:00
|
|
|
size_buf += 20;
|
|
|
|
buff_data = malloc(size_buf);
|
|
|
|
ESDWORD[buff_data] = size_buf;
|
2016-12-08 18:20:55 +01:00
|
|
|
ESDWORD[buff_data+4] = SLOT_DATA_TYPE_RAW;
|
2016-10-17 03:31:59 +02:00
|
|
|
ESINT[buff_data+8] = selected_count;
|
|
|
|
copy_buf_offset = buff_data + 10;
|
|
|
|
for (i=0; i<files.count; i++)
|
2016-10-15 23:39:03 +02:00
|
|
|
{
|
2016-11-01 13:14:17 +01:00
|
|
|
if (getElementSelectedFlag(i) == true) {
|
2016-10-30 20:17:46 +01:00
|
|
|
sprintf(copy_buf_offset,"%s/%s",#path,file_mas[i]*304+buf+72);
|
2016-10-17 03:31:59 +02:00
|
|
|
copy_buf_offset += strlen(copy_buf_offset) + 1;
|
|
|
|
}
|
2016-10-15 23:39:03 +02:00
|
|
|
}
|
2016-10-17 03:31:59 +02:00
|
|
|
if (selected_count==1) setElementSelectedFlag(files.cur_y, false);
|
2017-10-01 14:02:01 +02:00
|
|
|
Clipboard__SetSlotData(size_buf, buff_data);
|
2016-10-15 23:39:03 +02:00
|
|
|
cut_active = cut;
|
|
|
|
free(buff_data);
|
|
|
|
}
|
|
|
|
|
2016-10-16 23:06:28 +02:00
|
|
|
void Paste() {
|
2018-03-26 16:31:26 +02:00
|
|
|
copy_stak = free(copy_stak);
|
2016-10-16 23:06:28 +02:00
|
|
|
copy_stak = malloc(64000);
|
|
|
|
CreateThread(#PasteThread,copy_stak+64000-4);
|
|
|
|
}
|
|
|
|
|
2016-10-15 23:39:03 +02:00
|
|
|
void PasteThread()
|
|
|
|
{
|
|
|
|
char copy_rezult;
|
|
|
|
int j;
|
2016-10-17 03:31:59 +02:00
|
|
|
int paste_elements_count = 0;
|
2016-10-15 23:39:03 +02:00
|
|
|
dword buf;
|
2016-10-17 03:31:59 +02:00
|
|
|
dword path_offset;
|
2018-09-15 12:48:42 +02:00
|
|
|
dword file_count_paste = 0;
|
|
|
|
_dir_size paste_dir_size;
|
|
|
|
BDVK file_info_count;
|
|
|
|
|
2016-10-15 23:39:03 +02:00
|
|
|
copy_bar.value = 0;
|
2016-10-17 03:31:59 +02:00
|
|
|
|
2017-10-01 14:02:01 +02:00
|
|
|
buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
|
2015-03-09 19:49:34 +01:00
|
|
|
if (DSDWORD[buf+4] != 3) return;
|
2016-10-17 03:31:59 +02:00
|
|
|
paste_elements_count = ESINT[buf+8];
|
|
|
|
path_offset = buf + 10;
|
|
|
|
//calculate copy files count for progress bar
|
|
|
|
for (j = 0; j < paste_elements_count; j++) {
|
|
|
|
GetFileInfo(path_offset, #file_info_count);
|
2018-09-15 12:48:42 +02:00
|
|
|
if ( file_info_count.isfolder ) {
|
|
|
|
paste_dir_size.get(path_offset);
|
|
|
|
file_count_paste += paste_dir_size.files;
|
|
|
|
}
|
|
|
|
else file_count_paste++;
|
2016-10-17 03:31:59 +02:00
|
|
|
path_offset += strlen(path_offset) + 1;
|
2015-12-13 02:30:37 +01:00
|
|
|
}
|
2018-09-15 12:48:42 +02:00
|
|
|
copy_bar.max = file_count_paste;
|
2015-09-05 19:50:37 +02:00
|
|
|
|
2015-12-13 02:30:37 +01:00
|
|
|
if (cut_active) operation_flag = MOVE_FLAG;
|
|
|
|
else operation_flag = COPY_FLAG;
|
|
|
|
|
2016-10-17 03:31:59 +02:00
|
|
|
path_offset = buf + 10;
|
|
|
|
DisplayOperationForm();
|
|
|
|
for (j = 0; j < paste_elements_count; j++) {
|
|
|
|
strcpy(#copy_from, path_offset);
|
2015-09-05 19:50:37 +02:00
|
|
|
if (!copy_from) DialogExit();
|
2016-10-30 20:17:46 +01:00
|
|
|
sprintf(#copy_to, "%s/%s", #path, #copy_from+strrchr(#copy_from,'/'));
|
2015-12-13 02:30:37 +01:00
|
|
|
if (!strcmp(#copy_from,#copy_to))
|
|
|
|
{
|
2016-10-30 20:17:46 +01:00
|
|
|
sprintf(#copy_to, "%s/NEW_%s", #path, #copy_from+strrchr(#copy_from,'/'));
|
2015-12-13 02:30:37 +01:00
|
|
|
}
|
2014-03-26 13:51:42 +01:00
|
|
|
if (strstr(#copy_to, #copy_from))
|
|
|
|
{
|
|
|
|
notify("Copy directory into itself is a bad idea...");
|
2015-09-05 19:50:37 +02:00
|
|
|
DialogExit();
|
2014-03-26 13:51:42 +01:00
|
|
|
}
|
2015-12-13 02:30:37 +01:00
|
|
|
|
|
|
|
if (copy_rezult = copyf(#copy_from,#copy_to))
|
|
|
|
{
|
|
|
|
Write_Error(copy_rezult);
|
2018-10-20 13:00:31 +02:00
|
|
|
if (copy_rezult==8) DialogExit(); //not enough space
|
2015-12-13 02:30:37 +01:00
|
|
|
}
|
|
|
|
else if (cut_active)
|
|
|
|
{
|
2016-10-15 23:39:03 +02:00
|
|
|
strcpy(#file_path, #copy_from);
|
2015-12-13 02:30:37 +01:00
|
|
|
Del_File2(#copy_from, 0);
|
|
|
|
|
|
|
|
}
|
2016-10-17 03:31:59 +02:00
|
|
|
path_offset += strlen(path_offset) + 1;
|
2015-12-13 02:30:37 +01:00
|
|
|
}
|
2016-10-17 03:31:59 +02:00
|
|
|
cut_active=false;
|
2018-04-19 22:12:07 +02:00
|
|
|
if (info_after_copy.checked) notify(INFO_AFTER_COPY);
|
2015-11-25 22:10:21 +01:00
|
|
|
DialogExit();
|
2016-10-17 03:31:59 +02:00
|
|
|
}
|
2016-10-16 23:06:28 +02:00
|
|
|
|