Subversion Repositories Kolibri OS

Rev

Rev 3440 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3434 leency 1
// универсальность добавления /
2
// относительный путь относительно программы
3
 
4
void copyf(dword params)
5
{
6
	//copyf:  /sys/lib|/sys/lib2
7
	char from[4096], to[4096];
8
	BDVK from_atr;
9
	int border;
10
 
11
	if (!params) { notify("Error: no copyf params!"); return; }
12
	//ищем разделитель
13
	border = strchr(params, '|');
14
	if (!border) border = strchr(params, ' ');
15
 
16
	if (ESBYTE[params]<>'/') //абсолютный путь?
17
	{
18
		strcpy(#from, #program_path);
19
		strcat(#from, params);
20
		from[border+strlen(#program_path)-1]=NULL;
21
	}
22
	else
23
	{
24
		strcat(#from, params);
25
		from[border-1]=NULL;
26
	}
27
	strcpy(#to, params+border);
28
 
29
	GetFileInfo(#from, #from_atr);
30
	if (TestBit(from_atr.attr, 4)==1)
31
		CopyFolder(#from, #to);
32
	else
33
		CopyFile(#from, #to);
34
}
35
 
36
 
37
void CopyFolder(dword from, to)
38
{
39
	dword dirbuf, fcount, filename;
40
	int i, error, isdir;
41
	char copy_from[4096], copy_in[4096];
42
	char from2[4096], to2[4096];
43
 
44
	error = GetDir(#dirbuf, #fcount, from);
45
	if (error) { debug_error(from, error); return; }
46
 
47
	if ((strcmp(to, "/sys")!=0) && (strcmp(to, "/tmp9/1")!=0))
48
	{
49
		error = CreateDir(to);
50
		if (error) debug_error(to, error);
51
	}
52
	chrcat(to, '/');
53
	chrcat(from, '/');
54
 
55
	for (i=0; i
56
	{
57
		filename = i*304+dirbuf+72;
58
 
59
		isdir = TestBit(ESDWORD[filename-40], 4);
60
		if (isdir)
61
		{
62
			if ( (!strcmp(filename, ".")) || (!strcmp(filename, "..")) ) continue;
63
			strcpy(#from2, from);
64
			strcpy(#to2, to);
65
 
66
			strcat(#from2, filename);
67
			strcat(#to2, filename);
68
 
69
			CopyFolder(#from2, #to2);
70
		}
71
		else
72
		{
73
			strcpy(#copy_from, from);
74
			strcat(#copy_from, filename);
75
			strcpy(#copy_in, to);
76
			strcat(#copy_in, filename);
77
 
78
			copyf_Action(filename);
79
 
80
			error = CopyFile(#copy_from, #copy_in);
81
			if (error) error = CopyFile(#copy_from, #copy_in); // #2 :)
82
			if (error) debug_error(#copy_in, error);
83
		}
84
	}
85
	free(dirbuf);
86
}
87
 
88
unsigned char *ERROR_TEXT[]={
89
"Code #0 - No error",
90
"Error #1 - Base or partition of a hard disk is not defined",
91
"Error #2 - Function isn't supported for this file system",
92
"Error #3 - Unknown file system",
93
"Error #4 - Reserved, is never returned",
94
"Error #5 - File or folder not found",
95
"Error #6 - End of file, EOF",
96
"Error #7 - Pointer lies outside of application memory",
97
"Error #8 - Too less disk space",
98
"Error #9 - FAT table is destroyed",
99
"Error #10 - Access denied",
100
"Error #11 - Device error",
101
0, 0, 0, 0, 0, 0, 0, 0, 0,
102
0, 0, 0, 0, 0, 0, 0, 0, 0,
103
"Error #30 - Not enough memory",
104
"Error #31 - File is not executable",
105
"Error #32 - Too many processes",
106
0};
107
 
108
dword get_error(int N)
109
{
110
	char error[256];
111
	if (N<0) N*=-1;
112
	if (N<33)
113
	{
114
		strcpy(#error, ERROR_TEXT[N]);
115
	}
116
	else
117
	{
118
		strcpy(#error, itoa(N));
119
		strcat(#error, " - Unknown error number O_o");
120
	}
121
	return #error;
122
}
123
 
124
void debug_error(dword path, error_number)
125
{
126
	if (path) debug(path);
127
	debug(get_error(error_number));
128
}