forked from KolibriOS/kolibrios
Eolite 3.67: use one code for one and many elements copy; reduce memory use; faster operations because used pointers instead strcpy(); a lot of fixes and optimizations; unnecessary debug messages deleted()
git-svn-id: svn://kolibrios.org@6602 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7bf14f7dc9
commit
3c11bb4fbb
@ -420,22 +420,12 @@ void main()
|
|||||||
else Open(1);
|
else Open(1);
|
||||||
break;
|
break;
|
||||||
case 030: //Ctrl+A - select all files
|
case 030: //Ctrl+A - select all files
|
||||||
for (i=0; i<files.count; i++)
|
for (i=0; i<files.count; i++) setElementSelectedFlag(i, true);
|
||||||
{
|
|
||||||
selected_offset = file_mas[i]*304 + buf+32 + 7;
|
|
||||||
if (!i) if (!strncmp(selected_offset+33, "..", 2)) continue; //do not selec ".." directory
|
|
||||||
ESBYTE[selected_offset] = 1;
|
|
||||||
selected_count++;
|
|
||||||
}
|
|
||||||
List_ReDraw();
|
List_ReDraw();
|
||||||
DrawStatusBar();
|
DrawStatusBar();
|
||||||
break;
|
break;
|
||||||
case 022: //Ctrl+U - unselect all files
|
case 022: //Ctrl+U - unselect all files
|
||||||
for (i=0; i<files.count; i++)
|
for (i=0; i<files.count; i++) setElementSelectedFlag(i, false);
|
||||||
{
|
|
||||||
selected_offset = file_mas[i]*304 + buf+32 + 7;
|
|
||||||
ESBYTE[selected_offset] = 0;
|
|
||||||
}
|
|
||||||
selected_count = 0;
|
selected_count = 0;
|
||||||
List_ReDraw();
|
List_ReDraw();
|
||||||
DrawStatusBar();
|
DrawStatusBar();
|
||||||
@ -469,17 +459,8 @@ void main()
|
|||||||
break;
|
break;
|
||||||
case SCAN_CODE_INS:
|
case SCAN_CODE_INS:
|
||||||
selected_offset = file_mas[files.cur_y]*304 + buf+32 + 7;
|
selected_offset = file_mas[files.cur_y]*304 + buf+32 + 7;
|
||||||
if (files.cur_y==0) && (!strncmp(selected_offset+33, "..", 2)) goto _INSERT_END; //do not selec ".." directory
|
if (ESBYTE[selected_offset]) setElementSelectedFlag(files.cur_y, false);
|
||||||
if (ESBYTE[selected_offset])
|
else setElementSelectedFlag(files.cur_y, true);
|
||||||
{
|
|
||||||
ESBYTE[selected_offset]=0;
|
|
||||||
selected_count--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ESBYTE[selected_offset] = 1;
|
|
||||||
selected_count++;
|
|
||||||
}
|
|
||||||
_INSERT_END:
|
_INSERT_END:
|
||||||
files.KeyDown();
|
files.KeyDown();
|
||||||
List_ReDraw();
|
List_ReDraw();
|
||||||
@ -764,6 +745,7 @@ void Open_Dir(dword dir_path, redraw){
|
|||||||
int errornum, maxcount, i;
|
int errornum, maxcount, i;
|
||||||
if (redraw!=ONLY_SHOW)
|
if (redraw!=ONLY_SHOW)
|
||||||
{
|
{
|
||||||
|
selected_count = 0;
|
||||||
if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
|
if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
|
errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
|
||||||
@ -836,8 +818,6 @@ inline Sorting()
|
|||||||
|
|
||||||
void Del_Form()
|
void Del_Form()
|
||||||
{
|
{
|
||||||
dword selected_offset2;
|
|
||||||
int selected_count = 0;
|
|
||||||
byte f_count[128];
|
byte f_count[128];
|
||||||
int dform_x = files.w - 220 / 2 + files.x;
|
int dform_x = files.w - 220 / 2 + files.x;
|
||||||
if (!strncmp(#file_name,".",2)) || (!strncmp(#file_name,"..",2)) return;
|
if (!strncmp(#file_name,".",2)) || (!strncmp(#file_name,"..",2)) return;
|
||||||
@ -846,11 +826,6 @@ void Del_Form()
|
|||||||
if (!files.count) return;
|
if (!files.count) return;
|
||||||
DrawEolitePopup(T_YES, T_NO);
|
DrawEolitePopup(T_YES, T_NO);
|
||||||
WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,system.color.work_text,T_DELETE_FILE);
|
WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,system.color.work_text,T_DELETE_FILE);
|
||||||
for (i=0; i<files.count; i++)
|
|
||||||
{
|
|
||||||
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
|
||||||
if (ESBYTE[selected_offset2]) selected_count++;
|
|
||||||
}
|
|
||||||
if (selected_count)
|
if (selected_count)
|
||||||
{
|
{
|
||||||
sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
|
sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
|
||||||
|
@ -7,17 +7,27 @@ enum {NOCUT, CUT};
|
|||||||
|
|
||||||
Clipboard clipboard;
|
Clipboard clipboard;
|
||||||
|
|
||||||
|
void setElementSelectedFlag(dword n, bool state) {
|
||||||
|
dword selected_offset = file_mas[n]*304 + buf+32 + 7;
|
||||||
|
if (!n) if (!strncmp(selected_offset+33, "..", 2)) return; //do not selec ".." directory
|
||||||
|
ESBYTE[selected_offset] = state;
|
||||||
|
if (state==true) selected_count++;
|
||||||
|
if (state==false) selected_count--;
|
||||||
|
}
|
||||||
|
|
||||||
void Copy(dword pcth, char cut)
|
void Copy(dword pcth, char cut)
|
||||||
{
|
{
|
||||||
dword selected_offset2;
|
dword selected_offset2;
|
||||||
byte copy_t[4096];
|
byte copy_t[4096];
|
||||||
dword buff_data;
|
dword buff_data;
|
||||||
dword path_len = 0;
|
dword path_len = 0;
|
||||||
dword buffer_len = 0;
|
|
||||||
dword size_buf = 0;
|
dword size_buf = 0;
|
||||||
int ind = 0;
|
dword copy_buf_offset = 0;
|
||||||
if (selected_count)
|
|
||||||
{
|
if (files.count<=0) return; //no files
|
||||||
|
if (selected_count==0) setElementSelectedFlag(files.cur_y, true); //no element selected by "insert", so we copy current element
|
||||||
|
debugi(selected_count);
|
||||||
|
size_buf = 4;
|
||||||
for (i=0; i<files.count; i++)
|
for (i=0; i<files.count; i++)
|
||||||
{
|
{
|
||||||
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
||||||
@ -25,41 +35,27 @@ void Copy(dword pcth, char cut)
|
|||||||
strcpy(#copy_t, #path);
|
strcpy(#copy_t, #path);
|
||||||
strcat(#copy_t, file_mas[i]*304+buf+72);
|
strcat(#copy_t, file_mas[i]*304+buf+72);
|
||||||
path_len = strlen(#copy_t);
|
path_len = strlen(#copy_t);
|
||||||
size_buf = size_buf + path_len + 4;
|
size_buf += path_len + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
size_buf += 20;
|
||||||
buff_data = malloc(size_buf);
|
buff_data = malloc(size_buf);
|
||||||
ESDWORD[buff_data] = size_buf;
|
ESDWORD[buff_data] = size_buf;
|
||||||
ESDWORD[buff_data+4] = 3;
|
ESDWORD[buff_data+4] = 3;
|
||||||
ESINT[buff_data+8] = selected_count;
|
ESINT[buff_data+8] = selected_count;
|
||||||
|
copy_buf_offset = buff_data + 10;
|
||||||
for (i=0; i<files.count; i++)
|
for (i=0; i<files.count; i++)
|
||||||
{
|
{
|
||||||
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
||||||
if (ESBYTE[selected_offset2]) {
|
if (ESBYTE[selected_offset2]) {
|
||||||
strcpy(#copy_t, #path);
|
strcpy(copy_buf_offset, #path);
|
||||||
strcat(#copy_t, file_mas[i]*304+buf+72);
|
strcat(copy_buf_offset, file_mas[i]*304+buf+72);
|
||||||
path_len = strlen(#copy_t);
|
copy_buf_offset += strlen(copy_buf_offset) + 1;
|
||||||
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;
|
|
||||||
ind++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clipboard.SetSlotData(size_buf+10, buff_data);
|
WriteFile(size_buf, buff_data, "/rd/1/log.log");
|
||||||
}
|
if (selected_count==1) setElementSelectedFlag(files.cur_y, false);
|
||||||
else
|
clipboard.SetSlotData(size_buf, buff_data);
|
||||||
{
|
|
||||||
path_len = strlen(#file_path)+4;
|
|
||||||
buff_data = malloc(path_len);
|
|
||||||
ESDWORD[buff_data] = path_len;
|
|
||||||
ESDWORD[buff_data+4] = 3;
|
|
||||||
ESINT[buff_data+8] = 1;
|
|
||||||
ESDWORD[buff_data+10] = path_len;
|
|
||||||
strlcpy(buff_data+14, #file_path, path_len);;
|
|
||||||
clipboard.SetSlotData(path_len+10, buff_data);
|
|
||||||
}
|
|
||||||
cut_active = cut;
|
cut_active = cut;
|
||||||
free(buff_data);
|
free(buff_data);
|
||||||
}
|
}
|
||||||
@ -73,43 +69,39 @@ void PasteThread()
|
|||||||
{
|
{
|
||||||
char copy_rezult;
|
char copy_rezult;
|
||||||
int j;
|
int j;
|
||||||
int cnt = 0;
|
int paste_elements_count = 0;
|
||||||
dword buf;
|
dword buf;
|
||||||
dword path_len = 0;
|
dword path_offset;
|
||||||
dword buffer_len = 0;
|
|
||||||
file_count_copy = 0;
|
file_count_copy = 0;
|
||||||
copy_bar.value = 0;
|
copy_bar.value = 0;
|
||||||
|
|
||||||
buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
|
buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
|
||||||
if (DSDWORD[buf+4] != 3) return;
|
if (DSDWORD[buf+4] != 3) return;
|
||||||
cnt = ESINT[buf+8];
|
paste_elements_count = ESINT[buf+8];
|
||||||
for (j = 0; j < cnt; j++) {
|
path_offset = buf + 10;
|
||||||
path_len = ESDWORD[buf+10+buffer_len];
|
//calculate copy files count for progress bar
|
||||||
strlcpy(#copy_from, buf+10+buffer_len+4, path_len);
|
for (j = 0; j < paste_elements_count; j++) {
|
||||||
buffer_len = buffer_len + 4 + path_len;
|
GetFileInfo(path_offset, #file_info_count);
|
||||||
GetFileInfo(#copy_from, #file_info_count);
|
if ( file_info_count.isfolder ) DirFileCount(path_offset);
|
||||||
if ( file_info_count.isfolder ) DirFileCount(#copy_from);
|
|
||||||
else file_count_copy++;
|
else file_count_copy++;
|
||||||
|
path_offset += strlen(path_offset) + 1;
|
||||||
}
|
}
|
||||||
copy_bar.max = file_count_copy;
|
copy_bar.max = file_count_copy;
|
||||||
|
|
||||||
if (cut_active) operation_flag = MOVE_FLAG;
|
if (cut_active) operation_flag = MOVE_FLAG;
|
||||||
else operation_flag = COPY_FLAG;
|
else operation_flag = COPY_FLAG;
|
||||||
|
|
||||||
path_len = 0;
|
path_offset = buf + 10;
|
||||||
buffer_len = 0;
|
|
||||||
DisplayOperationForm();
|
DisplayOperationForm();
|
||||||
for (j = 0; j < cnt; j++) {
|
for (j = 0; j < paste_elements_count; j++) {
|
||||||
path_len = ESDWORD[buf+10+buffer_len];
|
strcpy(#copy_from, path_offset);
|
||||||
strlcpy(#copy_from, buf+10+buffer_len+4, path_len);
|
|
||||||
buffer_len = buffer_len + 4 + path_len;
|
|
||||||
if (!copy_from) DialogExit();
|
if (!copy_from) DialogExit();
|
||||||
strcpy(#copy_to, #path);
|
strcpy(#copy_to, #path);
|
||||||
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
||||||
if (!strcmp(#copy_from,#copy_to))
|
if (!strcmp(#copy_from,#copy_to))
|
||||||
{
|
{
|
||||||
strcpy(#copy_to, #path);
|
strcpy(#copy_to, #path);
|
||||||
strcat(#copy_to, "new_");
|
strcat(#copy_to, "NEW_");
|
||||||
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
|
||||||
}
|
}
|
||||||
if (strstr(#copy_to, #copy_from))
|
if (strstr(#copy_to, #copy_from))
|
||||||
@ -128,152 +120,10 @@ void PasteThread()
|
|||||||
Del_File2(#copy_from, 0);
|
Del_File2(#copy_from, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
path_offset += strlen(path_offset) + 1;
|
||||||
}
|
}
|
||||||
if (cut_active)
|
|
||||||
{
|
|
||||||
cut_active=false;
|
cut_active=false;
|
||||||
}
|
|
||||||
if (info_after_copy) notify(INFO_AFTER_COPY);
|
if (info_after_copy) notify(INFO_AFTER_COPY);
|
||||||
DialogExit();
|
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);
|
|
||||||
size_buf = size_buf + path_len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
strlcpy(buff_data+10+buffer_len+1, #copy_t, path_len);
|
|
||||||
buffer_len = buffer_len + path_len;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Paste() {
|
|
||||||
copy_stak = malloc(64000);
|
|
||||||
CreateThread(#PasteThread,copy_stak+64000-4);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
debugln("Step 1");
|
|
||||||
buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
|
|
||||||
if (DSDWORD[buf+4] != 3) return;
|
|
||||||
cnt = ESINT[buf+8];
|
|
||||||
for (j = 0; j < cnt; j++) {
|
|
||||||
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;
|
|
||||||
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;
|
|
||||||
|
|
||||||
debugln("Step 2");
|
|
||||||
path_len = 0;
|
|
||||||
buffer_len = 0;
|
|
||||||
DisplayOperationForm();
|
|
||||||
for (j = 0; j < cnt; j++) {
|
|
||||||
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;
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
debugln("Step 3000");
|
|
||||||
if (cut_active)
|
|
||||||
{
|
|
||||||
cut_active=false;
|
|
||||||
}
|
|
||||||
if (info_after_copy) notify(INFO_AFTER_COPY);
|
|
||||||
DialogExit();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,6 @@ void Del_File_Thread()
|
|||||||
|
|
||||||
void Del_File(byte dodel) {
|
void Del_File(byte dodel) {
|
||||||
del_active=0;
|
del_active=0;
|
||||||
debugi(dodel);
|
|
||||||
if (dodel)
|
if (dodel)
|
||||||
{
|
{
|
||||||
delete_stak = malloc(40000);
|
delete_stak = malloc(40000);
|
||||||
|
@ -206,7 +206,6 @@ void GetSizeMoreFiles(dword way)
|
|||||||
sprintf(#cur_file,"%s%s",way,file_mas[i]*304+buf+72);
|
sprintf(#cur_file,"%s%s",way,file_mas[i]*304+buf+72);
|
||||||
if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
|
if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
|
||||||
{
|
{
|
||||||
debugln(#cur_file);
|
|
||||||
GetSizeDir(#cur_file);
|
GetSizeDir(#cur_file);
|
||||||
dir_count++;
|
dir_count++;
|
||||||
}
|
}
|
||||||
@ -234,7 +233,6 @@ void properties_dialog()
|
|||||||
if (selected_count)
|
if (selected_count)
|
||||||
{
|
{
|
||||||
GetSizeMoreFiles(#path);
|
GetSizeMoreFiles(#path);
|
||||||
debugi(size_dir);
|
|
||||||
atr_readonly = 0;
|
atr_readonly = 0;
|
||||||
atr_hidden = 0;
|
atr_hidden = 0;
|
||||||
atr_system = 0;
|
atr_system = 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#define TITLE "Eolite File Manager v3.65"
|
#define TITLE "Eolite File Manager v3.67"
|
||||||
#define ABOUT_TITLE "EOLITE 3.65"
|
#define ABOUT_TITLE "EOLITE 3.67"
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
?define T_FILE "” ©«"
|
?define T_FILE "” ©«"
|
||||||
|
Loading…
Reference in New Issue
Block a user