Rev 7773 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7773 | Rev 7889 | ||
---|---|---|---|
1 | //IO library |
1 | //IO library |
2 | 2 | ||
3 | /* |
3 | /* |
4 | class IO: |
4 | class IO: |
5 | io.count(path) - êîëè÷åñòâî ôàéëîâ â äèððåêòîðèè path |
5 | io.count(path) - êîëè÷åñòâî ôàéëîâ â äèððåêòîðèè path |
6 | io.size(path) - ðàçìåð (ôàéëà/ïàïêè) path |
6 | io.size(path) - ðàçìåð (ôàéëà/ïàïêè) path |
7 | io.run(path,param) - çàïóñòèòü ôàéë path ñ ïàðàìåòðîì param |
7 | io.run(path,param) - çàïóñòèòü ôàéë path ñ ïàðàìåòðîì param |
8 | io.write(size,data,path) - çàïèñàòü ôàéë ñ äàííûìè data â äèððåêòîðèþ path |
8 | io.write(size,data,path) - çàïèñàòü ôàéë ñ äàííûìè data â äèððåêòîðèþ path |
9 | io.read(path) - ïðî÷èòàòü ôàéë path è âîçâðàòèòü óêàçàòåëü íà äàííûå |
9 | io.read(path) - ïðî÷èòàòü ôàéë path è âîçâðàòèòü óêàçàòåëü íà äàííûå |
10 | io.move(path1,path2) - ïåðåìåñòèòü (ôàéë/ïàïêó) èç path1 â path2 |
10 | io.move(path1,path2) - ïåðåìåñòèòü (ôàéë/ïàïêó) èç path1 â path2 |
11 | io.copy(path1,path2) - êîïèðîâàòü (ôàéë/ïàïêó) èç path1 â path2 |
11 | io.copy(path1,path2) - êîïèðîâàòü (ôàéë/ïàïêó) èç path1 â path2 |
12 | io.set(path,attribute) - óñòàíîâèòü àòòðèáóòû äëÿ (ôàéëà/ïàïêè) |
12 | io.set(path,attribute) - óñòàíîâèòü àòòðèáóòû äëÿ (ôàéëà/ïàïêè) |
13 | io.del(path) - óäàëèòü (ôàéë/ïàïêó) |
13 | io.del(path) - óäàëèòü (ôàéë/ïàïêó) |
14 | 14 | ||
15 | io.dir.load(path) - çàãðóçèòü â áóôôåð äàííûå ïàïêè path (ñëåäóåò î÷èùàòü áóôôåð ñîìàíäîé free!!!) |
15 | io.dir.load(path) - çàãðóçèòü â áóôôåð äàííûå ïàïêè path (ñëåäóåò î÷èùàòü áóôôåð ñîìàíäîé free!!!) |
16 | io.dir.position(number) - âîçâðàòèòü óêàçàòåëü èìåíè ôàéëà ïî ïîçèöèè number |
16 | io.dir.position(number) - âîçâðàòèòü óêàçàòåëü èìåíè ôàéëà ïî ïîçèöèè number |
17 | io.dir.make(path) - ñîçäàòü ïàïêó path |
17 | io.dir.make(path) - ñîçäàòü ïàïêó path |
18 | 18 | ||
19 | io.dir.buffer - áóôôåð äàííûõ çàãðóæåííîé ïàïêè ô-öèåé (io.dir.load) |
19 | io.dir.buffer - áóôôåð äàííûõ çàãðóæåííîé ïàïêè ô-öèåé (io.dir.load) |
20 | io.dir.count - êîëè÷åñòâî ôàéëîâ ôàãðóæåííîé ô-öèåé (io.count) |
20 | io.dir.count - êîëè÷åñòâî ôàéëîâ ôàãðóæåííîé ô-öèåé (io.count) |
21 | */ |
21 | */ |
22 | 22 | ||
23 | #ifndef INCLUDE_IO_H |
23 | #ifndef INCLUDE_IO_H |
24 | #define INCLUDE_IO_H |
24 | #define INCLUDE_IO_H |
25 | 25 | ||
26 | #ifndef INCLUDE_DATE_H |
26 | #ifndef INCLUDE_DATE_H |
27 | #include "../lib/date.h" |
27 | #include "../lib/date.h" |
28 | #endif |
28 | #endif |
29 | 29 | ||
30 | #ifdef LANG_RUS |
30 | #ifdef LANG_RUS |
31 | #define __T__GB "¡" |
31 | #define __T__GB "¡" |
32 | #define __T__MB "¡" |
32 | #define __T__MB "¡" |
33 | #define __T__KB "¡" |
33 | #define __T__KB "¡" |
34 | #define __T___B "" |
34 | #define __T___B "" |
35 | #else |
35 | #else |
36 | #define __T__GB "Gb" |
36 | #define __T__GB "Gb" |
37 | #define __T__MB "Mb" |
37 | #define __T__MB "Mb" |
38 | #define __T__KB "Kb" |
38 | #define __T__KB "Kb" |
39 | #define __T___B "B" |
39 | #define __T___B "B" |
40 | #endif |
40 | #endif |
41 | 41 | ||
42 | #define ATR_READONLY 000001b |
42 | #define ATR_READONLY 000001b |
43 | #define ATR_HIDDEN 000100b |
43 | #define ATR_HIDDEN 000100b |
44 | #define ATR_SYSTEM 010000b |
44 | #define ATR_SYSTEM 010000b |
45 | 45 | ||
46 | #define ATR_NOREADONLY 000010b |
46 | #define ATR_NOREADONLY 000010b |
47 | #define ATR_NOHIDDEN 001000b |
47 | #define ATR_NOHIDDEN 001000b |
48 | #define ATR_NOSYSTEM 100000b |
48 | #define ATR_NOSYSTEM 100000b |
49 | 49 | ||
50 | :enum |
50 | :enum |
51 | { |
51 | { |
52 | DIR_ALL, |
52 | DIR_ALL, |
53 | DIR_NOROOT, |
53 | DIR_NOROOT, |
54 | DIR_ONLYREAL |
54 | DIR_ONLYREAL |
55 | }; |
55 | }; |
56 | 56 | ||
57 | :struct ___f70{ |
57 | :struct ___f70{ |
58 | dword func; |
58 | dword func; |
59 | dword param1; |
59 | dword param1; |
60 | dword param2; |
60 | dword param2; |
61 | dword param3; |
61 | dword param3; |
62 | dword param4; |
62 | dword param4; |
63 | char rezerv; |
63 | char rezerv; |
64 | dword name; |
64 | dword name; |
65 | }__file_F70; |
65 | }__file_F70; |
66 | 66 | ||
67 | :int ___ReadDir(dword file_count, read_buffer, dir_path) |
67 | :int ___ReadDir(dword file_count, read_buffer, dir_path) |
68 | { |
68 | { |
69 | __file_F70.func = 1; |
69 | __file_F70.func = 1; |
70 | __file_F70.param1 = |
70 | __file_F70.param1 = |
71 | __file_F70.param2 = |
71 | __file_F70.param2 = |
72 | __file_F70.rezerv = 0; |
72 | __file_F70.rezerv = 0; |
73 | __file_F70.param3 = file_count; |
73 | __file_F70.param3 = file_count; |
74 | __file_F70.param4 = read_buffer; |
74 | __file_F70.param4 = read_buffer; |
75 | __file_F70.name = io.path.path(dir_path); |
75 | __file_F70.name = io.path.path(dir_path); |
76 | $mov eax,70 |
76 | $mov eax,70 |
77 | $mov ebx,#__file_F70.func |
77 | $mov ebx,#__file_F70.func |
78 | $int 0x40 |
78 | $int 0x40 |
79 | } |
79 | } |
80 | 80 | ||
81 | :dword ___GetFileInfo(dword file_path, bdvk_struct) |
81 | :dword ___GetFileInfo(dword file_path, bdvk_struct) |
82 | { |
82 | { |
83 | __file_F70.func = 5; |
83 | __file_F70.func = 5; |
84 | __file_F70.param1 = |
84 | __file_F70.param1 = |
85 | __file_F70.param2 = |
85 | __file_F70.param2 = |
86 | __file_F70.param3 = 0; |
86 | __file_F70.param3 = 0; |
87 | __file_F70.param4 = bdvk_struct; |
87 | __file_F70.param4 = bdvk_struct; |
88 | __file_F70.rezerv = 0; |
88 | __file_F70.rezerv = 0; |
89 | __file_F70.name = io.path.path(file_path); |
89 | __file_F70.name = io.path.path(file_path); |
90 | $mov eax,70 |
90 | $mov eax,70 |
91 | $mov ebx,#__file_F70.func |
91 | $mov ebx,#__file_F70.func |
92 | $int 0x40 |
92 | $int 0x40 |
93 | } |
93 | } |
94 | 94 | ||
95 | :struct ____BDVK { |
95 | :struct ____BDVK { |
96 | dword readonly:1, hidden:1, system:1, volume_label:1, isfolder:1, notarchived:1, :0; |
96 | dword readonly:1, hidden:1, system:1, volume_label:1, isfolder:1, notarchived:1, :0; |
97 | byte type_name; |
97 | byte type_name; |
98 | byte rez1, rez2, selected; |
98 | byte rez1, rez2, selected; |
99 | dword timecreate; |
99 | dword timecreate; |
100 | date datecreate; |
100 | date datecreate; |
101 | dword timelastaccess; |
101 | dword timelastaccess; |
102 | date datelastaccess; |
102 | date datelastaccess; |
103 | dword timelastedit; |
103 | dword timelastedit; |
104 | date datelastedit; |
104 | date datelastedit; |
105 | dword sizelo; |
105 | dword sizelo; |
106 | dword sizehi; |
106 | dword sizehi; |
107 | char name[518]; |
107 | char name[518]; |
108 | }; |
108 | }; |
109 | 109 | ||
110 | :struct __FILE |
110 | :struct __FILE |
111 | { |
111 | { |
112 | dword count; |
112 | dword count; |
113 | int del(...); |
113 | int del(...); |
114 | int read(...); |
114 | int read(...); |
115 | int write(...); |
115 | int write(...); |
116 | dword set(...); |
116 | dword set(...); |
117 | }; |
117 | }; |
118 | :dword __FILE::set(dword file_path) |
118 | :dword __FILE::set(dword file_path) |
119 | { |
119 | { |
120 | __file_F70.func = 6; |
120 | __file_F70.func = 6; |
121 | __file_F70.param1 = |
121 | __file_F70.param1 = |
122 | __file_F70.param2 = |
122 | __file_F70.param2 = |
123 | __file_F70.param3 = 0; |
123 | __file_F70.param3 = 0; |
124 | __file_F70.param4 = #io.BDVK; |
124 | __file_F70.param4 = #io.BDVK; |
125 | __file_F70.rezerv = 0; |
125 | __file_F70.rezerv = 0; |
126 | __file_F70.name = io.path.path(file_path); |
126 | __file_F70.name = io.path.path(file_path); |
127 | $mov eax,70 |
127 | $mov eax,70 |
128 | $mov ebx,#__file_F70.func |
128 | $mov ebx,#__file_F70.func |
129 | $int 0x40 |
129 | $int 0x40 |
130 | } |
130 | } |
131 | :int __FILE::del(dword PATH) |
131 | :int __FILE::del(dword PATH) |
132 | { |
132 | { |
133 | __file_F70.func = 8; |
133 | __file_F70.func = 8; |
134 | __file_F70.param1 = |
134 | __file_F70.param1 = |
135 | __file_F70.param2 = |
135 | __file_F70.param2 = |
136 | __file_F70.param3 = |
136 | __file_F70.param3 = |
137 | __file_F70.param4 = |
137 | __file_F70.param4 = |
138 | __file_F70.rezerv = 0; |
138 | __file_F70.rezerv = 0; |
139 | __file_F70.name = io.path.path(PATH); |
139 | __file_F70.name = io.path.path(PATH); |
140 | $mov eax,70 |
140 | $mov eax,70 |
141 | $mov ebx,#__file_F70.func |
141 | $mov ebx,#__file_F70.func |
142 | $int 0x40 |
142 | $int 0x40 |
143 | } |
143 | } |
144 | :int __FILE::read(dword read_pos, read_file_size, read_buffer, read_file_path) |
144 | :int __FILE::read(dword read_pos, read_file_size, read_buffer, read_file_path) |
145 | { |
145 | { |
146 | __file_F70.func = 0; |
146 | __file_F70.func = 0; |
147 | __file_F70.param1 = read_pos; |
147 | __file_F70.param1 = read_pos; |
148 | __file_F70.param2 = 0; |
148 | __file_F70.param2 = 0; |
149 | __file_F70.param3 = read_file_size; |
149 | __file_F70.param3 = read_file_size; |
150 | __file_F70.param4 = read_buffer; |
150 | __file_F70.param4 = read_buffer; |
151 | __file_F70.rezerv = 0; |
151 | __file_F70.rezerv = 0; |
152 | __file_F70.name = io.path.path(read_file_path); |
152 | __file_F70.name = io.path.path(read_file_path); |
153 | $mov eax,70 |
153 | $mov eax,70 |
154 | $mov ebx,#__file_F70.func |
154 | $mov ebx,#__file_F70.func |
155 | $int 0x40 |
155 | $int 0x40 |
156 | } |
156 | } |
157 | :int __FILE::write(dword write_file_size, write_buffer, write_file_path) |
157 | :int __FILE::write(dword write_offset, write_len, write_buffer, wfile_path) |
158 | { |
158 | { |
159 | __file_F70.func = 2; |
159 | __file_F70.func = 2; |
160 | __file_F70.param1 = 0; |
160 | __file_F70.param1 = write_offset; |
161 | __file_F70.param2 = 0; |
161 | __file_F70.param2 = 0; |
162 | __file_F70.param3 = write_file_size; |
162 | __file_F70.param3 = write_len; |
163 | __file_F70.param4 = write_buffer; |
163 | __file_F70.param4 = write_buffer; |
164 | __file_F70.rezerv = 0; |
164 | __file_F70.rezerv = 0; |
165 | __file_F70.name = io.path.path(write_file_path); |
165 | __file_F70.name = io.path.path(wfile_path); |
166 | $mov eax,70 |
166 | $mov eax,70 |
167 | $mov ebx,#__file_F70.func |
167 | $mov ebx,#__file_F70.func |
168 | $int 0x40 |
168 | $int 0x40 |
169 | } |
169 | } |
170 | :struct __DIR |
170 | :struct __DIR |
171 | { |
171 | { |
172 | int make(dword name); |
172 | int make(dword name); |
173 | dword load(...); |
173 | dword load(...); |
174 | dword position(dword i); |
174 | dword position(dword i); |
175 | dword buffer; |
175 | dword buffer; |
176 | signed count; |
176 | signed count; |
177 | }; |
177 | }; |
178 | :dword __DIR::position(dword i) |
178 | :dword __DIR::position(dword i) |
179 | { |
179 | { |
180 | return i*304+buffer+72; |
180 | return i*304+buffer+72; |
181 | } |
181 | } |
182 | :int __DIR::make(dword new_folder_path) |
182 | :int __DIR::make(dword new_folder_path) |
183 | { |
183 | { |
184 | __file_F70.func = 9; |
184 | __file_F70.func = 9; |
185 | __file_F70.param1 = |
185 | __file_F70.param1 = |
186 | __file_F70.param2 = |
186 | __file_F70.param2 = |
187 | __file_F70.param3 = |
187 | __file_F70.param3 = |
188 | __file_F70.param4 = |
188 | __file_F70.param4 = |
189 | __file_F70.rezerv = 0; |
189 | __file_F70.rezerv = 0; |
190 | __file_F70.name = io.path.path(new_folder_path); |
190 | __file_F70.name = io.path.path(new_folder_path); |
191 | $mov eax,70 |
191 | $mov eax,70 |
192 | $mov ebx,#__file_F70.func |
192 | $mov ebx,#__file_F70.func |
193 | $int 0x40 |
193 | $int 0x40 |
194 | } |
194 | } |
195 | 195 | ||
196 | :dword __DIR::load(dword PATH;byte options) |
196 | :dword __DIR::load(dword PATH;byte options) |
197 | { |
197 | { |
198 | io.count(PATH); |
198 | io.count(PATH); |
199 | if(count!=-1) |
199 | if(count!=-1) |
200 | { |
200 | { |
201 | buffer = malloc(count+1*304+32); |
201 | buffer = malloc(count+1*304+32); |
202 | ___ReadDir(count, buffer, PATH); |
202 | ___ReadDir(count, buffer, PATH); |
203 | if (options == DIR_ONLYREAL) |
203 | if (options == DIR_ONLYREAL) |
204 | { |
204 | { |
205 | if (!strcmp(".",buffer+72)){count--; memmov(buffer,buffer+304,count*304);} |
205 | if (!strcmp(".",buffer+72)){count--; memmov(buffer,buffer+304,count*304);} |
206 | if (!strcmp("..",buffer+72)){count--; memmov(buffer,buffer+304,count*304);} |
206 | if (!strcmp("..",buffer+72)){count--; memmov(buffer,buffer+304,count*304);} |
207 | return buffer; |
207 | return buffer; |
208 | } |
208 | } |
209 | if (options == DIR_NOROOT) |
209 | if (options == DIR_NOROOT) |
210 | { |
210 | { |
211 | if (!strcmp(".",buffer+72)) memmov(buffer,buffer+304,count*304-304); |
211 | if (!strcmp(".",buffer+72)) memmov(buffer,buffer+304,count*304-304); |
212 | return buffer; |
212 | return buffer; |
213 | } |
213 | } |
214 | return buffer; |
214 | return buffer; |
215 | } |
215 | } |
216 | return NULL; |
216 | return NULL; |
217 | } |
217 | } |
218 | 218 | ||
219 | :void get_path_name(dword BUF,PATH) |
219 | :void get_path_name(dword BUF,PATH) |
220 | { |
220 | { |
221 | dword beg = PATH; |
221 | dword beg = PATH; |
222 | dword pos = PATH; |
222 | dword pos = PATH; |
223 | dword sav = PATH; |
223 | dword sav = PATH; |
224 | dword i; |
224 | dword i; |
225 | while(DSBYTE[pos]) |
225 | while(DSBYTE[pos]) |
226 | { |
226 | { |
227 | if(DSBYTE[pos]=='/')sav = pos; |
227 | if(DSBYTE[pos]=='/')sav = pos; |
228 | pos++; |
228 | pos++; |
229 | } |
229 | } |
230 | i = sav-beg; |
230 | i = sav-beg; |
231 | while(i) |
231 | while(i) |
232 | { |
232 | { |
233 | DSBYTE[BUF] = DSBYTE[beg]; |
233 | DSBYTE[BUF] = DSBYTE[beg]; |
234 | beg++; |
234 | beg++; |
235 | BUF++; |
235 | BUF++; |
236 | i--; |
236 | i--; |
237 | } |
237 | } |
238 | DSBYTE[BUF] = 0; |
238 | DSBYTE[BUF] = 0; |
239 | } |
239 | } |
240 | 240 | ||
241 | :struct __PATH |
241 | :struct __PATH |
242 | { |
242 | { |
243 | dword file(...); |
243 | dword file(...); |
244 | dword path(...); |
244 | dword path(...); |
245 | }; |
245 | }; |
246 | 246 | ||
247 | :char __PATH_NEW[4096]; |
247 | :char __PATH_NEW[4096]; |
248 | :dword __PATH::path(dword PATH) |
248 | :dword __PATH::path(dword PATH) |
249 | { |
249 | { |
250 | char self_dir[4096]; |
250 | char self_dir[4096]; |
251 | dword pos; |
251 | dword pos; |
252 | 252 | ||
253 | get_path_name(#self_dir,I_Path); |
253 | get_path_name(#self_dir,I_Path); |
254 | 254 | ||
255 | if(!PATH) return #self_dir; |
255 | if(!PATH) return #self_dir; |
256 | pos = PATH; |
256 | pos = PATH; |
257 | if(DSBYTE[pos]=='/') || (!strncmp(PATH,"./",2)) |
257 | if(DSBYTE[pos]=='/') || (!strncmp(PATH,"./",2)) |
258 | { |
258 | { |
259 | return PATH; |
259 | return PATH; |
260 | } |
260 | } |
261 | strcpy(#__PATH_NEW, #self_dir); |
261 | strcpy(#__PATH_NEW, #self_dir); |
262 | chrcat(#__PATH_NEW, '/'); |
262 | chrcat(#__PATH_NEW, '/'); |
263 | strcpy(#__PATH_NEW, PATH); |
263 | strcpy(#__PATH_NEW, PATH); |
264 | return #__PATH_NEW; |
264 | return #__PATH_NEW; |
265 | } |
265 | } |
266 | 266 | ||
267 | :dword __PATH::file(dword name) |
267 | :dword __PATH::file(dword name) |
268 | { |
268 | { |
269 | dword ret; |
269 | dword ret; |
270 | ret = name; |
270 | ret = name; |
271 | while(DSBYTE[name]) |
271 | while(DSBYTE[name]) |
272 | { |
272 | { |
273 | if(DSBYTE[name]=='/')ret = name+1; |
273 | if(DSBYTE[name]=='/')ret = name+1; |
274 | name++; |
274 | name++; |
275 | } |
275 | } |
276 | return ret; |
276 | return ret; |
277 | } |
277 | } |
278 | 278 | ||
279 | :struct IO |
279 | :struct IO |
280 | { |
280 | { |
281 | dword buffer_data; |
281 | dword buffer_data; |
282 | dword size_dir; |
282 | dword size_dir; |
283 | dword count_dirs,count_files; |
283 | dword count_dirs,count_files; |
284 | signed FILES_SIZE; |
284 | signed FILES_SIZE; |
285 | dword file_name; |
285 | dword file_name; |
286 | double size(...); |
286 | double size(...); |
287 | dword get_size_dir(dword name); |
287 | dword get_size_dir(dword name); |
288 | signed count(dword path); |
288 | signed count(dword path); |
289 | signed int run(dword path,param); |
289 | signed int run(dword path,param); |
290 | byte del(...); |
290 | byte del(...); |
291 | dword read(...); |
291 | dword read(...); |
292 | int write(...); |
292 | int write(...); |
293 | byte copy(...); |
293 | byte copy(...); |
294 | byte move(...); |
294 | byte move(...); |
295 | dword set(...); |
295 | dword set(...); |
296 | dword readKPACK(dword path1); |
296 | dword readKPACK(dword path1); |
297 | dword convert_size(); |
297 | dword convert_size(); |
298 | __DIR dir; |
298 | __DIR dir; |
299 | __PATH path; |
299 | __PATH path; |
300 | __FILE file; |
300 | __FILE file; |
301 | ____BDVK BDVK; |
301 | ____BDVK BDVK; |
302 | }io; |
302 | }io; |
303 | :byte __ConvertSize_size_prefix[8]; |
303 | :byte __ConvertSize_size_prefix[8]; |
304 | :dword IO::convert_size() |
304 | :dword IO::convert_size() |
305 | { |
305 | { |
306 | byte size_nm[3]; |
306 | byte size_nm[3]; |
307 | dword bytes; |
307 | dword bytes; |
308 | bytes = FILES_SIZE; |
308 | bytes = FILES_SIZE; |
309 | if (bytes>=1073741824) strlcpy(#size_nm, __T__GB,2); |
309 | if (bytes>=1073741824) strlcpy(#size_nm, __T__GB,2); |
310 | else if (bytes>=1048576) strlcpy(#size_nm, __T__MB,2); |
310 | else if (bytes>=1048576) strlcpy(#size_nm, __T__MB,2); |
311 | else if (bytes>=1024) strlcpy(#size_nm, __T__KB,2); |
311 | else if (bytes>=1024) strlcpy(#size_nm, __T__KB,2); |
312 | else strlcpy(#size_nm, __T___B,1); |
312 | else strlcpy(#size_nm, __T___B,1); |
313 | while (bytes>1023) bytes/=1024; |
313 | while (bytes>1023) bytes/=1024; |
314 | sprintf(#__ConvertSize_size_prefix,"%d %s",bytes,#size_nm); |
314 | sprintf(#__ConvertSize_size_prefix,"%d %s",bytes,#size_nm); |
315 | return #__ConvertSize_size_prefix; |
315 | return #__ConvertSize_size_prefix; |
316 | } |
316 | } |
317 | :dword IO::readKPACK(dword path1) |
317 | :dword IO::readKPACK(dword path1) |
318 | { |
318 | { |
319 | EAX = 68; |
319 | EAX = 68; |
320 | EBX = 27; |
320 | EBX = 27; |
321 | ECX = path1; |
321 | ECX = path1; |
322 | $int 0x40; |
322 | $int 0x40; |
323 | FILES_SIZE = EDX; |
323 | FILES_SIZE = EDX; |
324 | buffer_data = EAX; |
324 | buffer_data = EAX; |
325 | return buffer_data; |
325 | return buffer_data; |
326 | } |
326 | } |
327 | :int IO::write(dword PATH,data) |
327 | :int IO::write(dword PATH,data) |
328 | { |
328 | { |
329 | file.write(0,strlen(data),data,PATH); |
329 | return file.write(0,strlen(data),data,PATH); |
330 | } |
330 | } |
331 | :char BYTE_HEAD_FILE_KPCK[4]; |
331 | :char BYTE_HEAD_FILE_KPCK[4]; |
332 | :dword IO::read(dword PATH) |
332 | :dword IO::read(dword PATH) |
333 | { |
333 | { |
334 | int result; |
334 | int result; |
335 | ___GetFileInfo(PATH, #BDVK); |
335 | ___GetFileInfo(PATH, #BDVK); |
336 | if(BDVK.isfolder)return false; |
336 | if(BDVK.isfolder)return false; |
337 | file.read(0,4,#BYTE_HEAD_FILE_KPCK,PATH); |
337 | file.read(0,4,#BYTE_HEAD_FILE_KPCK,PATH); |
338 | IF(DSDWORD[#BYTE_HEAD_FILE_KPCK]=='KCPK')return readKPACK(PATH); |
338 | IF(DSDWORD[#BYTE_HEAD_FILE_KPCK]=='KCPK')return readKPACK(PATH); |
339 | FILES_SIZE = BDVK.sizelo; |
339 | FILES_SIZE = BDVK.sizelo; |
340 | buffer_data = malloc(FILES_SIZE+1); |
340 | buffer_data = malloc(FILES_SIZE+1); |
341 | result = file.read(0,FILES_SIZE,buffer_data,PATH); |
341 | result = file.read(0,FILES_SIZE,buffer_data,PATH); |
342 | if (result!=0) buffer_data = free(buffer_data); //file read failed |
342 | if (result!=0) buffer_data = free(buffer_data); //file read failed |
343 | return buffer_data; |
343 | return buffer_data; |
344 | } |
344 | } |
345 | 345 | ||
346 | :signed int IO::run(dword rpath,rparam) |
346 | :signed int IO::run(dword rpath,rparam) |
347 | { |
347 | { |
348 | __file_F70.func = 7; |
348 | __file_F70.func = 7; |
349 | __file_F70.param1 = |
349 | __file_F70.param1 = |
350 | __file_F70.param3 = |
350 | __file_F70.param3 = |
351 | __file_F70.param4 = |
351 | __file_F70.param4 = |
352 | __file_F70.rezerv = 0; |
352 | __file_F70.rezerv = 0; |
353 | __file_F70.param2 = rparam; |
353 | __file_F70.param2 = rparam; |
354 | __file_F70.name = path.path(rpath); |
354 | __file_F70.name = path.path(rpath); |
355 | $mov eax,70 |
355 | $mov eax,70 |
356 | $mov ebx,#__file_F70.func |
356 | $mov ebx,#__file_F70.func |
357 | $int 0x40 |
357 | $int 0x40 |
- | 358 | return EAX; |
|
358 | } |
359 | } |
359 | :signed IO::count(dword PATH) |
360 | :signed IO::count(dword PATH) |
360 | { |
361 | { |
361 | byte buf[32]; |
362 | byte buf[32]; |
362 | if(!___ReadDir(0, #buf, PATH)) |
363 | if(!___ReadDir(0, #buf, PATH)) |
363 | { |
364 | { |
364 | dir.count = ESDWORD[#buf+8]; |
365 | dir.count = ESDWORD[#buf+8]; |
365 | return dir.count; |
366 | return dir.count; |
366 | } |
367 | } |
367 | return -1; |
368 | return -1; |
368 | } |
369 | } |
369 | 370 | ||
370 | :double IO::size(dword PATH) |
371 | :double IO::size(dword PATH) |
371 | { |
372 | { |
372 | dword i,tmp_buf,count_dir,count_file; |
373 | dword i,tmp_buf,count_dir,count_file; |
373 | dword filename; |
374 | dword filename; |
374 | double size_tmp; |
375 | double size_tmp; |
375 | double tmp; |
376 | double tmp; |
376 | if(!PATH)return 0; |
377 | if(!PATH)return 0; |
377 | if(___GetFileInfo(PATH, #BDVK))return -1; |
378 | if(___GetFileInfo(PATH, #BDVK))return -1; |
378 | if(BDVK.isfolder) |
379 | if(BDVK.isfolder) |
379 | { |
380 | { |
380 | tmp_buf = dir.load(PATH,DIR_ONLYREAL); |
381 | tmp_buf = dir.load(PATH,DIR_ONLYREAL); |
381 | if(dir.count<1)return 0; |
382 | if(dir.count<1)return 0; |
382 | count_dir = dir.count; |
383 | count_dir = dir.count; |
383 | i = 0; |
384 | i = 0; |
384 | size_tmp = 0; |
385 | size_tmp = 0; |
385 | count_file = malloc(4096); |
386 | count_file = malloc(4096); |
386 | while(i |
387 | while(i |
387 | { |
388 | { |
388 | filename = i*304+tmp_buf+72; |
389 | filename = i*304+tmp_buf+72; |
389 | sprintf(count_file,"%s/%s",PATH,filename); |
390 | sprintf(count_file,"%s/%s",PATH,filename); |
390 | tmp = size(count_file); |
391 | tmp = size(count_file); |
391 | if(tmp==-1)return -1; |
392 | if(tmp==-1)return -1; |
392 | size_tmp += tmp; |
393 | size_tmp += tmp; |
393 | i++; |
394 | i++; |
394 | if (TestBit(ESDWORD[filename-40], 4))count_dirs++; |
395 | if (TestBit(ESDWORD[filename-40], 4))count_dirs++; |
395 | else count_files++; |
396 | else count_files++; |
396 | } |
397 | } |
397 | 398 | ||
398 | free(tmp_buf); |
399 | free(tmp_buf); |
399 | free(count_file); |
400 | free(count_file); |
400 | FILES_SIZE = size_tmp; |
401 | FILES_SIZE = size_tmp; |
401 | return FILES_SIZE; |
402 | return FILES_SIZE; |
402 | } |
403 | } |
403 | FILES_SIZE = BDVK.sizelo; |
404 | FILES_SIZE = BDVK.sizelo; |
404 | count_files++; |
405 | count_files++; |
405 | return FILES_SIZE; |
406 | return FILES_SIZE; |
406 | } |
407 | } |
407 | :byte IO::del(dword PATH) |
408 | :byte IO::del(dword PATH) |
408 | { |
409 | { |
409 | dword i,tmp_buf,count_dir,count_file; |
410 | dword i,tmp_buf,count_dir,count_file; |
410 | if(!PATH)return 0; |
411 | if(!PATH)return 0; |
411 | if(___GetFileInfo(PATH, #BDVK))return false; |
412 | if(___GetFileInfo(PATH, #BDVK))return false; |
412 | if(BDVK.isfolder) |
413 | if(BDVK.isfolder) |
413 | { |
414 | { |
414 | tmp_buf = dir.load(PATH,DIR_ONLYREAL); |
415 | tmp_buf = dir.load(PATH,DIR_ONLYREAL); |
415 | count_dir = dir.count; |
416 | count_dir = dir.count; |
416 | i = 0; |
417 | i = 0; |
417 | count_file = malloc(4096); |
418 | count_file = malloc(4096); |
418 | while(i |
419 | while(i |
419 | { |
420 | { |
420 | sprintf(count_file,"%s/%s",PATH,i*304+tmp_buf+72); |
421 | sprintf(count_file,"%s/%s",PATH,i*304+tmp_buf+72); |
421 | if(!del(count_file))return false; |
422 | if(!del(count_file))return false; |
422 | i++; |
423 | i++; |
423 | } |
424 | } |
424 | free(tmp_buf); |
425 | free(tmp_buf); |
425 | free(count_file); |
426 | free(count_file); |
426 | } |
427 | } |
427 | file.del(PATH); |
428 | file.del(PATH); |
428 | return true; |
429 | return true; |
429 | } |
430 | } |
430 | :dword IO::set(dword PATH,atr) |
431 | :dword IO::set(dword PATH,atr) |
431 | { |
432 | { |
432 | dword i,tmp_buf,count_dir,count_file; |
433 | dword i,tmp_buf,count_dir,count_file; |
433 | byte cmd_read,cmd_hide,cmd_system; |
434 | byte cmd_read,cmd_hide,cmd_system; |
434 | if(!PATH)return 0; |
435 | if(!PATH)return 0; |
435 | if(___GetFileInfo(PATH, #BDVK))return false; |
436 | if(___GetFileInfo(PATH, #BDVK))return false; |
436 | cmd_read = atr&11b; |
437 | cmd_read = atr&11b; |
437 | atr>>=2; |
438 | atr>>=2; |
438 | cmd_hide = atr&11b; |
439 | cmd_hide = atr&11b; |
439 | atr>>=2; |
440 | atr>>=2; |
440 | cmd_system = atr&11b; |
441 | cmd_system = atr&11b; |
441 | if(BDVK.isfolder) |
442 | if(BDVK.isfolder) |
442 | { |
443 | { |
443 | tmp_buf = dir.load(PATH,DIR_ONLYREAL); |
444 | tmp_buf = dir.load(PATH,DIR_ONLYREAL); |
444 | count_dir = dir.count; |
445 | count_dir = dir.count; |
445 | i = 0; |
446 | i = 0; |
446 | count_file = malloc(4096); |
447 | count_file = malloc(4096); |
447 | while(i |
448 | while(i |
448 | { |
449 | { |
449 | sprintf(count_file,"%s/%s",PATH,i*304+tmp_buf+72); |
450 | sprintf(count_file,"%s/%s",PATH,i*304+tmp_buf+72); |
450 | file.set(PATH,atr); |
451 | file.set(PATH,atr); |
451 | i++; |
452 | i++; |
452 | } |
453 | } |
453 | free(tmp_buf); |
454 | free(tmp_buf); |
454 | free(count_file); |
455 | free(count_file); |
455 | return 0; |
456 | return 0; |
456 | } |
457 | } |
457 | if(cmd_read) |
458 | if(cmd_read) |
458 | { |
459 | { |
459 | if(cmd_read&01b)BDVK.readonly = true; |
460 | if(cmd_read&01b)BDVK.readonly = true; |
460 | else BDVK.readonly = false; |
461 | else BDVK.readonly = false; |
461 | } |
462 | } |
462 | if(cmd_hide) |
463 | if(cmd_hide) |
463 | { |
464 | { |
464 | if(cmd_hide&01b)BDVK.hidden = true; |
465 | if(cmd_hide&01b)BDVK.hidden = true; |
465 | else BDVK.hidden = false; |
466 | else BDVK.hidden = false; |
466 | } |
467 | } |
467 | if(cmd_system) |
468 | if(cmd_system) |
468 | { |
469 | { |
469 | if(cmd_system&01b)BDVK.system = true; |
470 | if(cmd_system&01b)BDVK.system = true; |
470 | else BDVK.system = false; |
471 | else BDVK.system = false; |
471 | } |
472 | } |
472 | file.set(PATH); |
473 | file.set(PATH); |
473 | } |
474 | } |
474 | :byte IO::copy(dword PATH,PATH1) |
475 | :byte IO::copy(dword PATH,PATH1) |
475 | { |
476 | { |
476 | dword i,tmp_buf,count_dir,count_file; |
477 | dword i,tmp_buf,count_dir,count_file; |
477 | dword _path_; |
478 | dword _path_; |
478 | byte ret; |
479 | byte ret; |
479 | if(!PATH)return 0; |
480 | if(!PATH)return 0; |
480 | if(___GetFileInfo(PATH, #BDVK))return false; |
481 | if(___GetFileInfo(PATH, #BDVK))return false; |
481 | _path_ = malloc(4096); |
482 | _path_ = malloc(4096); |
482 | if(BDVK.isfolder) |
483 | if(BDVK.isfolder) |
483 | { |
484 | { |
484 | sprintf(_path_,"%s/%s",PATH1,path.file(PATH)); |
485 | sprintf(_path_,"%s/%s",PATH1,path.file(PATH)); |
485 | dir.make(_path_); |
486 | dir.make(_path_); |
486 | tmp_buf = dir.load(PATH,DIR_ONLYREAL); |
487 | tmp_buf = dir.load(PATH,DIR_ONLYREAL); |
487 | count_dir = dir.count; |
488 | count_dir = dir.count; |
488 | i = 0; |
489 | i = 0; |
489 | count_file = malloc(4096); |
490 | count_file = malloc(4096); |
490 | while(i |
491 | while(i |
491 | { |
492 | { |
492 | sprintf(count_file,"%s/%s",PATH,i*304+tmp_buf+72); |
493 | sprintf(count_file,"%s/%s",PATH,i*304+tmp_buf+72); |
493 | if(!copy(count_file,_path_))return false; |
494 | if(!copy(count_file,_path_))return false; |
494 | i++; |
495 | i++; |
495 | } |
496 | } |
496 | free(tmp_buf); |
497 | free(tmp_buf); |
497 | free(count_file); |
498 | free(count_file); |
498 | free(_path_); |
499 | free(_path_); |
499 | return true; |
500 | return true; |
500 | } |
501 | } |
501 | read(PATH); |
502 | read(PATH); |
502 | sprintf(_path_,"%s/%s",PATH1,path.file(PATH)); |
503 | sprintf(_path_,"%s/%s",PATH1,path.file(PATH)); |
503 | ret = file.write(FILES_SIZE,buffer_data,_path_); |
504 | ret = file.write(FILES_SIZE,buffer_data,_path_); |
504 | free(_path_); |
505 | free(_path_); |
505 | if(!ret)return true; |
506 | if(!ret)return true; |
506 | return false; |
507 | return false; |
507 | } |
508 | } |
508 | :byte IO::move(dword PATH,PATH1) |
509 | :byte IO::move(dword PATH,PATH1) |
509 | { |
510 | { |
510 | if(copy(PATH,PATH1))if(del(PATH))return true; |
511 | if(copy(PATH,PATH1))if(del(PATH))return true; |
511 | return false; |
512 | return false; |
512 | } |
513 | } |
513 | 514 | ||
514 | #endif |
515 | #endif |
515 | > |
516 | > |
516 | > |
517 | > |
517 | > |
518 | > |
518 | >1)return> |
519 | >1)return> |