forked from KolibriOS/kolibrios
Eolite 3.85: copy files with size bigger than free ram, fix hang and memory leak when copy
git-svn-id: svn://kolibrios.org@7210 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
bddfb2f439
commit
f3a69d6d86
@ -296,7 +296,6 @@ void TWebBrowser::SetStyle() {
|
||||
}
|
||||
if (opened) {
|
||||
if (strcmp(#header, #version) != 0) {
|
||||
debugln("!!!!!!!!!!!!!!!!!!!!!!");
|
||||
ChangeCharset(charsets[cur_encoding], "CP866", #header);
|
||||
sprintf(#header, "%s - %s", #header, #version);
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ void Copy(dword pcth, char cut)
|
||||
}
|
||||
|
||||
void Paste() {
|
||||
copy_stak = free(copy_stak);
|
||||
copy_stak = malloc(64000);
|
||||
CreateThread(#PasteThread,copy_stak+64000-4);
|
||||
}
|
||||
|
@ -33,9 +33,9 @@
|
||||
?define T_CD "CD-ROM "
|
||||
?define T_FD "Floppy disk "
|
||||
?define T_HD "Hard disk "
|
||||
?define T_SATA "SATA disk"
|
||||
?define T_USB "USB disk"
|
||||
?define T_RAM "RAM disk"
|
||||
?define T_SATA "SATA disk "
|
||||
?define T_USB "USB disk "
|
||||
?define T_RAM "RAM disk "
|
||||
#endif
|
||||
|
||||
struct _SystemDiscs
|
||||
|
@ -1,5 +1,5 @@
|
||||
#define TITLE "Eolite File Manager v3.83"
|
||||
#define ABOUT_TITLE "EOLITE 3.83"
|
||||
#define TITLE "Eolite File Manager v3.85"
|
||||
#define ABOUT_TITLE "EOLITE 3.85"
|
||||
|
||||
#ifdef LANG_RUS
|
||||
?define T_FILE "” ©«"
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
if (!from1) || (!in1)
|
||||
{
|
||||
notify("Error: too less copyf params!");
|
||||
notify(from1);
|
||||
notify(in1);
|
||||
notify("Error: too few copyf() params!");
|
||||
return;
|
||||
}
|
||||
if (error = GetFileInfo(from1, #CopyFile_atr1))
|
||||
@ -28,7 +26,7 @@
|
||||
return CopyFolder(from1, in1);
|
||||
else
|
||||
{
|
||||
Operation_Draw_Progress(from1+strchr(from1, '/'));
|
||||
Operation_Draw_Progress(from1+strrchr(from1, '/'));
|
||||
return CopyFile(from1, in1);
|
||||
}
|
||||
}
|
||||
@ -37,27 +35,24 @@
|
||||
{
|
||||
BDVK CopyFile_atr;
|
||||
dword error, cbuf;
|
||||
dword block;
|
||||
|
||||
if (error = GetFileInfo(copy_from3, #CopyFile_atr))
|
||||
{
|
||||
debugln("Error: CopyFile->GetFileInfo");
|
||||
}
|
||||
else if (GetFreeRAM()-1024*1024 < CopyFile_atr.sizelo) //GetFreeRam-1Mb and convert to bytes
|
||||
else
|
||||
{
|
||||
debugln("Error: CopyFile->File size is bigger than RAM avilable");
|
||||
error = 30;
|
||||
}
|
||||
else {
|
||||
cbuf = malloc(CopyFile_atr.sizelo);
|
||||
if (error = ReadFile(0, CopyFile_atr.sizelo, cbuf, copy_from3))
|
||||
if (GetFreeRAM()-1024*1024 < CopyFile_atr.sizelo) //GetFreeRam-1Mb and convert to bytes
|
||||
{
|
||||
debugln("Error: CopyFile->ReadFile");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error = WriteFile(CopyFile_atr.sizelo, cbuf, copy_in3)) debugln("Error: CopyFile->WriteFile");
|
||||
if (error = CopyFileByBlocks(CopyFile_atr.sizelo, copy_from3, copy_in3))
|
||||
debugln("Error: CopyFile->CopyFileByBlocks");
|
||||
}
|
||||
else {
|
||||
if (error = CopyFileAtOnce(CopyFile_atr.sizelo, copy_from3, copy_in3))
|
||||
debugln("Error: CopyFile->CopyFileAtOnce");
|
||||
}
|
||||
}
|
||||
free(cbuf);
|
||||
if (error) debug_error(copy_from3, error);
|
||||
return error;
|
||||
}
|
||||
@ -96,7 +91,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Operation_Draw_Progress(filename+strchr(filename, '/'));
|
||||
Operation_Draw_Progress(filename+strrchr(filename, '/'));
|
||||
if (error=CopyFile(#copy_from2, #copy_in2))
|
||||
{
|
||||
if (fabs(error)==8) { debugln("Stop copying."); break;} //TODO: may be need grobal var like stop_all
|
||||
|
@ -129,33 +129,30 @@
|
||||
// Ïðî÷èòàòü ôàéë //
|
||||
////////////////////////////
|
||||
:f70 read_file_70;
|
||||
:int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path)
|
||||
:int ReadFile(dword offset, data_size, buffer, file_path)
|
||||
{
|
||||
read_file_70.func = 0;
|
||||
read_file_70.param1 = read_pos;
|
||||
read_file_70.param1 = offset;
|
||||
read_file_70.param2 = 0;
|
||||
read_file_70.param3 = read_file_size;
|
||||
read_file_70.param4 = read_buffer;
|
||||
read_file_70.param3 = data_size;
|
||||
read_file_70.param4 = buffer;
|
||||
read_file_70.rezerv = 0;
|
||||
read_file_70.name = read_file_path;
|
||||
read_file_70.name = file_path;
|
||||
$mov eax,70
|
||||
$mov ebx,#read_file_70.func
|
||||
$int 0x40
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Çàïèñàòü ôàéë //
|
||||
///////////////////////////
|
||||
:f70 write_file_70;
|
||||
:int WriteFile(dword write_file_size, write_buffer, write_file_path)
|
||||
:int WriteFile(dword data_size, buffer, file_path)
|
||||
{
|
||||
write_file_70.func = 2;
|
||||
write_file_70.param1 = 0;
|
||||
write_file_70.param2 = 0;
|
||||
write_file_70.param3 = write_file_size;
|
||||
write_file_70.param4 = write_buffer;
|
||||
write_file_70.param3 = data_size;
|
||||
write_file_70.param4 = buffer;
|
||||
write_file_70.rezerv = 0;
|
||||
write_file_70.name = write_file_path;
|
||||
write_file_70.name = file_path;
|
||||
$mov eax,70
|
||||
$mov ebx,#write_file_70.func
|
||||
$int 0x40
|
||||
@ -165,19 +162,20 @@
|
||||
// WriteInFileThatAlredyExists //
|
||||
////////////////////////////////////////
|
||||
:f70 write_file_offset_70;
|
||||
:int WriteFileWithOffset(dword write_data_size, write_buffer, write_file_path, offset)
|
||||
:int WriteFileWithOffset(dword offset, data_size, buffer, file_path)
|
||||
{
|
||||
write_file_offset_70.func = 3;
|
||||
write_file_offset_70.param1 = offset;
|
||||
write_file_offset_70.param2 = 0;
|
||||
write_file_offset_70.param3 = write_data_size;
|
||||
write_file_offset_70.param4 = write_buffer;
|
||||
write_file_offset_70.param3 = data_size;
|
||||
write_file_offset_70.param4 = buffer;
|
||||
write_file_offset_70.rezerv = 0;
|
||||
write_file_offset_70.name = write_file_path;
|
||||
write_file_offset_70.name = file_path;
|
||||
$mov eax,70
|
||||
$mov ebx,#write_file_offset_70.func
|
||||
$int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
// Ïðî÷èòàòü ïàïêó //
|
||||
@ -346,4 +344,47 @@ enum
|
||||
|
||||
return #size;
|
||||
}
|
||||
|
||||
:int CopyFileAtOnce(dword size, copyFrom, copyTo)
|
||||
dword cbuf;
|
||||
int error;
|
||||
{
|
||||
cbuf = malloc(size);
|
||||
if (error = ReadFile(0, size, cbuf, copyFrom))
|
||||
{
|
||||
debugln("Error: CopyFileAtOnce->ReadFile");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error = WriteFile(size, cbuf, copyTo)) debugln("Error: CopyFileAtOnce->WriteFile");
|
||||
}
|
||||
free(cbuf);
|
||||
return error;
|
||||
}
|
||||
|
||||
:int CopyFileByBlocks(dword size, copyFrom, copyTo)
|
||||
dword cbuf;
|
||||
int error=-1;
|
||||
dword offpos=0;
|
||||
int block_size=1024*4024; //copy by 4 MiBs
|
||||
{
|
||||
cbuf = malloc(block_size);
|
||||
WriteFile(0, 0, copyTo); //create file
|
||||
while(offpos < size)
|
||||
{
|
||||
error = ReadFile(offpos, block_size, cbuf, copyFrom);
|
||||
if (error = 6) { //File ended before last byte was readed
|
||||
block_size = EBX;
|
||||
error=0;
|
||||
}
|
||||
else
|
||||
if (error!=0) break;
|
||||
if (error = WriteFileWithOffset(offpos, block_size, cbuf, copyTo)) break;
|
||||
offpos += block_size;
|
||||
}
|
||||
free(cbuf);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user