Subversion Repositories Kolibri OS

Rev

Rev 6980 | Rev 7219 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6980 Rev 7210
Line 12... Line 12...
12
	dword error;
12
	dword error;
13
	BDVK CopyFile_atr1;
13
	BDVK CopyFile_atr1;
Line 14... Line 14...
14
 
14
 
15
	if (!from1) || (!in1)
15
	if (!from1) || (!in1)
16
	{
16
	{
17
		notify("Error: too less copyf params!");
-
 
18
		notify(from1);
-
 
19
		notify(in1);
17
		notify("Error: too few copyf() params!");
20
		return;
18
		return;
21
	}
19
	}
22
	if (error = GetFileInfo(from1, #CopyFile_atr1))
20
	if (error = GetFileInfo(from1, #CopyFile_atr1))
23
	{
21
	{
Line 26... Line 24...
26
	}
24
	}
27
	if (dir_exists(from1))
25
	if (dir_exists(from1))
28
		return CopyFolder(from1, in1);
26
		return CopyFolder(from1, in1);
29
	else
27
	else
30
	{
28
	{
31
		Operation_Draw_Progress(from1+strchr(from1, '/'));
29
		Operation_Draw_Progress(from1+strrchr(from1, '/'));
32
		return CopyFile(from1, in1);
30
		return CopyFile(from1, in1);
33
	}
31
	}
34
}
32
}
Line 35... Line 33...
35
 
33
 
36
:int CopyFile(dword copy_from3, copy_in3)
34
:int CopyFile(dword copy_from3, copy_in3)
37
{
35
{
38
	BDVK CopyFile_atr;
36
	BDVK CopyFile_atr;
-
 
37
	dword error, cbuf;
-
 
38
	dword block;
39
	dword error, cbuf;
39
 
40
	if (error = GetFileInfo(copy_from3, #CopyFile_atr))
40
	if (error = GetFileInfo(copy_from3, #CopyFile_atr))
41
	{
41
	{
42
		debugln("Error: CopyFile->GetFileInfo");
42
		debugln("Error: CopyFile->GetFileInfo");
43
	}
-
 
-
 
43
	}
44
	else if (GetFreeRAM()-1024*1024 < CopyFile_atr.sizelo) //GetFreeRam-1Mb and convert to bytes
44
	else 
45
	{
-
 
46
		debugln("Error: CopyFile->File size is bigger than RAM avilable");
-
 
47
		error = 30;
-
 
48
	}
-
 
49
	else {
-
 
50
		cbuf = malloc(CopyFile_atr.sizelo);
45
	{
51
		if (error = ReadFile(0, CopyFile_atr.sizelo, cbuf, copy_from3))
46
		if (GetFreeRAM()-1024*1024 < CopyFile_atr.sizelo) //GetFreeRam-1Mb and convert to bytes
-
 
47
		{
52
		{
48
			if (error = CopyFileByBlocks(CopyFile_atr.sizelo, copy_from3, copy_in3))
53
			debugln("Error: CopyFile->ReadFile");
49
				debugln("Error: CopyFile->CopyFileByBlocks");
54
		}
50
		}
55
		else
-
 
56
		{
51
		else {
-
 
52
			if (error = CopyFileAtOnce(CopyFile_atr.sizelo, copy_from3, copy_in3))
57
			if (error = WriteFile(CopyFile_atr.sizelo, cbuf, copy_in3)) debugln("Error: CopyFile->WriteFile");
53
				debugln("Error: CopyFile->CopyFileAtOnce");
58
		}
54
		}		
59
	}
-
 
60
	free(cbuf);
55
	}
61
	if (error) debug_error(copy_from3, error);
56
	if (error) debug_error(copy_from3, error);
62
	return error;
57
	return error;
Line 63... Line 58...
63
}
58
}
Line 94... Line 89...
94
			if ( (!strncmp(filename, ".",1)) || (!strncmp(filename, "..",2)) ) continue;
89
			if ( (!strncmp(filename, ".",1)) || (!strncmp(filename, "..",2)) ) continue;
95
			CopyFolder(#copy_from2, #copy_in2);
90
			CopyFolder(#copy_from2, #copy_in2);
96
		}
91
		}
97
		else
92
		else
98
		{
93
		{
99
			Operation_Draw_Progress(filename+strchr(filename, '/'));
94
			Operation_Draw_Progress(filename+strrchr(filename, '/'));
100
			if (error=CopyFile(#copy_from2, #copy_in2))
95
			if (error=CopyFile(#copy_from2, #copy_in2))
101
			{
96
			{
102
				if (fabs(error)==8) { debugln("Stop copying."); break;} //TODO: may be need grobal var like stop_all
97
				if (fabs(error)==8) { debugln("Stop copying."); break;} //TODO: may be need grobal var like stop_all
103
				error=CopyFile(#copy_from2, #copy_in2); // #2 :)
98
				error=CopyFile(#copy_from2, #copy_in2); // #2 :)
104
			}
99
			}