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