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
|
|
|
|
2014-01-06 01:36:08 +01:00
|
|
|
Clipboard clipboard;
|
|
|
|
|
2013-04-04 19:07:38 +02:00
|
|
|
void Copy(dword pcth, char cut)
|
|
|
|
{
|
2015-03-09 19:02:10 +01:00
|
|
|
dword selected_offset2;
|
|
|
|
byte copy_t[4096];
|
|
|
|
dword buff_data;
|
2016-10-15 23:39:03 +02:00
|
|
|
dword path_len = 0;
|
|
|
|
dword buffer_len = 0;
|
|
|
|
dword size_buf = 0;
|
2015-08-07 04:11:35 +02:00
|
|
|
int ind = 0;
|
2015-03-09 19:02:10 +01:00
|
|
|
if (selected_count)
|
|
|
|
{
|
2016-10-15 23:39:03 +02:00
|
|
|
for (i=0; i<files.count; i++)
|
|
|
|
{
|
|
|
|
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
|
|
|
if (ESBYTE[selected_offset2]) {
|
|
|
|
strcpy(#copy_t, #path);
|
|
|
|
strcat(#copy_t, file_mas[i]*304+buf+72);
|
|
|
|
path_len = strlen(#copy_t);
|
2016-10-16 23:06:28 +02:00
|
|
|
size_buf = size_buf + path_len + 4;
|
2016-10-15 23:39:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buff_data = malloc(size_buf);
|
|
|
|
ESDWORD[buff_data] = size_buf;
|
2015-03-09 19:02:10 +01:00
|
|
|
ESDWORD[buff_data+4] = 3;
|
2016-10-15 23:39:03 +02:00
|
|
|
ESINT[buff_data+8] = selected_count;
|
|
|
|
|
2014-11-05 23:34:25 +01:00
|
|
|
for (i=0; i<files.count; i++)
|
|
|
|
{
|
2015-03-09 19:02:10 +01:00
|
|
|
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
|
|
|
if (ESBYTE[selected_offset2]) {
|
|
|
|
strcpy(#copy_t, #path);
|
2016-10-15 23:39:03 +02:00
|
|
|
strcat(#copy_t, file_mas[i]*304+buf+72);
|
|
|
|
path_len = strlen(#copy_t);
|
2016-10-16 23:06:28 +02:00
|
|
|
ESDWORD[buff_data+10+buffer_len] = path_len;
|
|
|
|
strlcpy(buff_data+10+4+buffer_len, #copy_t, path_len);
|
|
|
|
buffer_len = buffer_len + 4 + path_len;
|
2015-03-09 19:02:10 +01:00
|
|
|
ind++;
|
2014-12-01 21:11:26 +01:00
|
|
|
}
|
2015-03-09 19:02:10 +01:00
|
|
|
}
|
2016-10-15 23:39:03 +02:00
|
|
|
clipboard.SetSlotData(size_buf+10, buff_data);
|
2015-03-09 19:02:10 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-16 23:06:28 +02:00
|
|
|
path_len = strlen(#file_path)+4;
|
|
|
|
buff_data = malloc(path_len);
|
|
|
|
ESDWORD[buff_data] = path_len;
|
2015-03-09 19:02:10 +01:00
|
|
|
ESDWORD[buff_data+4] = 3;
|
|
|
|
ESINT[buff_data+8] = 1;
|
2016-10-16 23:06:28 +02:00
|
|
|
ESDWORD[buff_data+10] = path_len;
|
|
|
|
strlcpy(buff_data+14, #file_path, path_len);;
|
|
|
|
clipboard.SetSlotData(path_len+10, buff_data);
|
2015-03-09 19:02:10 +01:00
|
|
|
}
|
2013-04-04 19:07:38 +02:00
|
|
|
cut_active = cut;
|
2014-12-01 21:11:26 +01:00
|
|
|
free(buff_data);
|
2013-04-04 19:07:38 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 14:23:52 +02:00
|
|
|
void Paste() {
|
2015-12-14 15:50:28 +01:00
|
|
|
copy_stak = malloc(64000);
|
|
|
|
CreateThread(#PasteThread,copy_stak+64000-4);
|
2015-07-23 14:23:52 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 14:15:53 +02:00
|
|
|
void PasteThread()
|
2013-04-04 19:07:38 +02:00
|
|
|
{
|
2013-10-15 01:16:04 +02:00
|
|
|
char copy_rezult;
|
2014-11-05 23:34:25 +01:00
|
|
|
int j;
|
2015-03-09 19:49:34 +01:00
|
|
|
int cnt = 0;
|
2014-04-21 05:01:45 +02:00
|
|
|
dword buf;
|
2016-10-15 23:39:03 +02:00
|
|
|
dword path_len = 0;
|
|
|
|
dword buffer_len = 0;
|
|
|
|
file_count_copy = 0;
|
2015-08-07 04:11:35 +02:00
|
|
|
copy_bar.value = 0;
|
2016-10-15 23:39:03 +02:00
|
|
|
|
|
|
|
buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
|
|
|
|
if (DSDWORD[buf+4] != 3) return;
|
|
|
|
cnt = ESINT[buf+8];
|
|
|
|
for (j = 0; j < cnt; j++) {
|
2016-10-16 23:06:28 +02:00
|
|
|
path_len = ESDWORD[buf+10+buffer_len];
|
|
|
|
strlcpy(#copy_from, buf+10+buffer_len+4, path_len);
|
|
|
|
buffer_len = buffer_len + 4 + path_len;
|
2016-10-15 23:39:03 +02:00
|
|
|
GetFileInfo(#copy_from, #file_info_count);
|
|
|
|
if ( file_info_count.isfolder ) DirFileCount(#copy_from);
|
|
|
|
else file_count_copy++;
|
|
|
|
}
|
|
|
|
copy_bar.max = file_count_copy;
|
|
|
|
|
|
|
|
if (cut_active) operation_flag = MOVE_FLAG;
|
|
|
|
else operation_flag = COPY_FLAG;
|
2015-11-25 22:10:21 +01:00
|
|
|
|
2016-10-15 23:39:03 +02:00
|
|
|
path_len = 0;
|
|
|
|
buffer_len = 0;
|
|
|
|
DisplayOperationForm();
|
|
|
|
for (j = 0; j < cnt; j++) {
|
2016-10-16 23:06:28 +02:00
|
|
|
path_len = ESDWORD[buf+10+buffer_len];
|
|
|
|
strlcpy(#copy_from, buf+10+buffer_len+4, path_len);
|
|
|
|
buffer_len = buffer_len + 4 + path_len;
|
2016-10-15 23:39:03 +02:00
|
|
|
if (!copy_from) DialogExit();
|
|
|
|
strcpy(#copy_to, #path);
|
|
|
|
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
|
|
|
if (!strcmp(#copy_from,#copy_to))
|
|
|
|
{
|
|
|
|
strcpy(#copy_to, #path);
|
|
|
|
strcat(#copy_to, "new_");
|
|
|
|
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
|
|
|
}
|
|
|
|
if (strstr(#copy_to, #copy_from))
|
|
|
|
{
|
|
|
|
notify("Copy directory into itself is a bad idea...");
|
|
|
|
DialogExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_rezult = copyf(#copy_from,#copy_to))
|
|
|
|
{
|
|
|
|
Write_Error(copy_rezult);
|
|
|
|
}
|
|
|
|
else if (cut_active)
|
|
|
|
{
|
|
|
|
strcpy(#file_path, #copy_from);
|
|
|
|
Del_File2(#copy_from, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cut_active)
|
|
|
|
{
|
|
|
|
cut_active=false;
|
|
|
|
}
|
|
|
|
if (info_after_copy) notify(INFO_AFTER_COPY);
|
|
|
|
DialogExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Another version of the function copy/paste
|
|
|
|
|
|
|
|
/*
|
|
|
|
void Copy(dword pcth, char cut)
|
|
|
|
{
|
|
|
|
dword selected_offset2;
|
|
|
|
byte copy_t[4096];
|
|
|
|
dword buff_data;
|
|
|
|
dword path_len = 0;
|
|
|
|
dword buffer_len = 0;
|
|
|
|
dword size_buf = 0;
|
|
|
|
int ind = 0;
|
|
|
|
if (selected_count)
|
|
|
|
{
|
|
|
|
for (i=0; i<files.count; i++)
|
|
|
|
{
|
|
|
|
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
|
|
|
if (ESBYTE[selected_offset2]) {
|
|
|
|
strcpy(#copy_t, #path);
|
|
|
|
strcat(#copy_t, file_mas[i]*304+buf+72);
|
|
|
|
path_len = strlen(#copy_t);
|
2016-10-16 23:06:28 +02:00
|
|
|
size_buf = size_buf + path_len;
|
2016-10-15 23:39:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buff_data = malloc(size_buf);
|
|
|
|
ESDWORD[buff_data] = size_buf;
|
|
|
|
ESDWORD[buff_data+4] = 3;
|
|
|
|
ESINT[buff_data+8] = selected_count;
|
|
|
|
|
|
|
|
for (i=0; i<files.count; i++)
|
|
|
|
{
|
|
|
|
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
|
|
|
if (ESBYTE[selected_offset2]) {
|
|
|
|
strcpy(#copy_t, #path);
|
|
|
|
strcat(#copy_t, file_mas[i]*304+buf+72);
|
|
|
|
path_len = strlen(#copy_t);
|
2016-10-16 23:06:28 +02:00
|
|
|
strlcpy(buff_data+10+buffer_len+1, #copy_t, path_len);
|
|
|
|
buffer_len = buffer_len + path_len;
|
2016-10-15 23:39:03 +02:00
|
|
|
ind++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clipboard.SetSlotData(size_buf+10, buff_data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buff_data = malloc(4106);
|
|
|
|
ESDWORD[buff_data] = 4106;
|
|
|
|
ESDWORD[buff_data+4] = 3;
|
|
|
|
ESINT[buff_data+8] = 1;
|
|
|
|
strlcpy(buff_data+10, #file_path, 4096);;
|
|
|
|
clipboard.SetSlotData(4106, buff_data);
|
|
|
|
}
|
|
|
|
cut_active = cut;
|
|
|
|
free(buff_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-16 23:06:28 +02:00
|
|
|
void Paste() {
|
|
|
|
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;
|
|
|
|
int cnt = 0;
|
|
|
|
dword buf;
|
|
|
|
dword path_len = 0;
|
|
|
|
dword buffer_len = 0;
|
|
|
|
file_count_copy = 0;
|
|
|
|
copy_bar.value = 0;
|
2016-10-16 23:06:28 +02:00
|
|
|
debugln("Step 1");
|
2016-10-15 23:39:03 +02:00
|
|
|
buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
|
2015-03-09 19:49:34 +01:00
|
|
|
if (DSDWORD[buf+4] != 3) return;
|
2014-11-05 23:34:25 +01:00
|
|
|
cnt = ESINT[buf+8];
|
2015-12-13 02:30:37 +01:00
|
|
|
for (j = 0; j < cnt; j++) {
|
2016-10-16 23:06:28 +02:00
|
|
|
if (j==0) strlcpy(#copy_from, buf+10+buffer_len);
|
|
|
|
else strlcpy(#copy_from, buf+10+buffer_len+1);
|
|
|
|
buffer_len = buffer_len + path_len;
|
2015-12-13 02:30:37 +01:00
|
|
|
GetFileInfo(#copy_from, #file_info_count);
|
|
|
|
if ( file_info_count.isfolder ) DirFileCount(#copy_from);
|
|
|
|
else file_count_copy++;
|
|
|
|
}
|
|
|
|
copy_bar.max = file_count_copy;
|
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-16 23:06:28 +02:00
|
|
|
debugln("Step 2");
|
|
|
|
path_len = 0;
|
2016-10-15 23:39:03 +02:00
|
|
|
buffer_len = 0;
|
|
|
|
DisplayOperationForm();
|
2015-03-09 19:49:34 +01:00
|
|
|
for (j = 0; j < cnt; j++) {
|
2016-10-16 23:06:28 +02:00
|
|
|
if (j==0) strlcpy(#copy_from, buf+10+buffer_len);
|
|
|
|
else strlcpy(#copy_from, buf+10+buffer_len+1);
|
|
|
|
debugln(#copy_from);
|
|
|
|
path_len = strlen(#copy_from);
|
|
|
|
debugi(path_len);
|
|
|
|
debug("Step ");
|
|
|
|
debugi(j);
|
|
|
|
debugln(" ");
|
|
|
|
buffer_len = buffer_len + path_len;
|
2015-09-05 19:50:37 +02:00
|
|
|
if (!copy_from) DialogExit();
|
2013-04-04 19:07:38 +02:00
|
|
|
strcpy(#copy_to, #path);
|
|
|
|
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
2015-12-13 02:30:37 +01:00
|
|
|
if (!strcmp(#copy_from,#copy_to))
|
|
|
|
{
|
|
|
|
strcpy(#copy_to, #path);
|
|
|
|
strcat(#copy_to, "new_");
|
|
|
|
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
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-16 23:06:28 +02:00
|
|
|
debugln("Step 3000");
|
2015-12-13 02:30:37 +01:00
|
|
|
if (cut_active)
|
|
|
|
{
|
|
|
|
cut_active=false;
|
2015-11-25 22:10:21 +01:00
|
|
|
}
|
2015-02-24 13:48:22 +01:00
|
|
|
if (info_after_copy) notify(INFO_AFTER_COPY);
|
2015-11-25 22:10:21 +01:00
|
|
|
DialogExit();
|
2016-10-16 23:06:28 +02:00
|
|
|
}*/
|
|
|
|
|
|
|
|
|