Rev 3363 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3363 | leency | 1 | // универсальность добавления / |
2 | // относительный путь относительно программы |
||
3 | |||
4 | void copyf(dword params) |
||
3432 | leency | 5 | { |
6 | //copyf: /sys/lib|/sys/lib2 |
||
3363 | leency | 7 | char from[4096], to[4096]; |
8 | BDVK from_atr; |
||
9 | int border; |
||
3432 | leency | 10 | |
3363 | leency | 11 | if (!params) { notify("Error: no copyf params!"); return; } |
3432 | leency | 12 | //ищем разделитель |
3363 | leency | 13 | border = strchr(params, '|'); |
14 | if (!border) border = strchr(params, ' '); |
||
15 | |||
3432 | leency | 16 | if (ESBYTE[params]<>'/') //абсолютный путь? |
3363 | leency | 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); |
||
3432 | leency | 32 | else |
3363 | leency | 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); |
||
3432 | leency | 45 | if (error) { debug_error(from, error); return; } |
3363 | leency | 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 | if (CheckEvent()==evReDraw) { DefineWindow("Installation Started", "Stop"); ShowProgress("Copying files..."); } |
||
79 | ShowProgress(NULL); |
||
80 | DrawBar(TEXTX, BLACK_H+50, Form.cwidth-TEXTX, 12, 0xFFFfff); |
||
81 | WriteText(TEXTX, BLACK_H+50, 0x80, 0, filename); |
||
82 | |||
83 | error = CopyFile(#copy_from, #copy_in); |
||
84 | if (error) error = CopyFile(#copy_from, #copy_in); // #2 :) |
||
85 | if (error) debug_error(#copy_in, error); |
||
86 | } |
||
87 | } |
||
88 | free(dirbuf); |
||
89 | } |
||
90 | |||
91 | |||
92 | unsigned char *ERROR_TEXT[]={ |
||
93 | "Code #0 - No error", |
||
94 | "Error #1 - Base or partition of a hard disk is not defined", |
||
95 | "Error #2 - Function isn't supported for this file system", |
||
96 | "Error #3 - Unknown file system", |
||
97 | "Error #4 - Reserved, is never returned", |
||
98 | "Error #5 - File or folder not found", |
||
99 | "Error #6 - End of file, EOF", |
||
100 | "Error #7 - Pointer lies outside of application memory", |
||
3432 | leency | 101 | "Error #8 - Too less disk space", |
3363 | leency | 102 | "Error #9 - FAT table is destroyed", |
103 | "Error #10 - Access denied", |
||
104 | "Error #11 - Device error", |
||
105 | 0, 0, 0, 0, 0, 0, 0, 0, 0, |
||
106 | 0, 0, 0, 0, 0, 0, 0, 0, 0, |
||
107 | "Error #30 - Not enough memory", |
||
108 | "Error #31 - File is not executable", |
||
109 | "Error #32 - Too many processes", |
||
110 | 0}; |
||
111 | |||
112 | void debug_error(int path, error_number) |
||
113 | { |
||
114 | char error[256]; |
||
115 | if (path) debug(path); |
||
116 | if (error_number<0) error_number*=-1; |
||
117 | if (error_number<33) |
||
118 | { |
||
119 | strcpy(#error, ERROR_TEXT[error_number]); |
||
120 | } |
||
121 | else |
||
122 | { |
||
123 | strcpy(#error, itoa(error_number)); |
||
124 | strcat(#error, " - Unknown error number O_o"); |
||
125 | } |
||
126 | debug(#error); |
||
127 | }33) |