Rev 134 | Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ; ; |
||
3 | ; FILE COPY - system module for copy ; |
||
4 | ; files.Prog for SYS X-TREE BROWSER v22 ; |
||
5 | ; ; |
||
6 | ; Create by Pavlushin Evgeni waptap@mail.ru ; |
||
7 | ; homepage www.deck4.narod.ru ; |
||
8 | ; ; |
||
9 | ; On base SYSTREE FILE COPIER 1.02 ; |
||
10 | ; Ivan Poddubny ivan-yar@bk.ru ; |
||
205 | heavyiron | 11 | ; ; |
31 | halyavin | 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
13 | |||
14 | ;Данная прога еще сырая и глючная но уже кое как работает |
||
15 | use32 |
||
16 | org 0x0 |
||
17 | |||
18 | db 'MENUET01' ; 8 byte id |
||
19 | dd 0x01 ; header version |
||
20 | dd START ; start of code |
||
21 | dd I_END ; size of image |
||
134 | diamond | 22 | dd 0x10000 ; memory for app |
31 | halyavin | 23 | dd 0x10000 ; esp |
24 | dd param_area , 0x0 ; I_Param , I_Icon |
||
25 | |||
26 | include 'lang.inc' |
||
27 | include 'macros.inc' ; very useful stuff for MeOS |
||
28 | include 'ascl.inc' |
||
29 | |||
30 | START: ; start of execution |
||
31 | |||
32 | ; Параметры: |
||
134 | diamond | 33 | ; db n1 = длина пути к источнику |
34 | ; times n1 db ? = путь к источнику |
||
35 | ; db n2 = длина пути к приёмнику |
||
36 | ; times n2 db ? = путь к приёмнику |
||
37 | ; db 0 |
||
38 | |||
31 | halyavin | 39 | ;get param |
134 | diamond | 40 | mov eax, 15 |
41 | lea esi, [param_area+1] |
||
42 | movzx ecx, byte [esi-1] |
||
43 | jecxz err_exit |
||
44 | mov edi, source |
||
45 | rep movsb |
||
46 | mov byte [edi], 0 |
||
47 | inc eax |
||
48 | movzx ecx, byte [esi] |
||
49 | inc esi |
||
50 | jecxz err_exit |
||
51 | mov edi, destination |
||
52 | rep movsb |
||
53 | mov byte [edi], 0 |
||
31 | halyavin | 54 | |
55 | call draw_window |
||
56 | call copy_file |
||
57 | |||
58 | dexit: |
||
59 | wtevent red,key,button |
||
60 | jmp dexit |
||
61 | red: |
||
62 | call draw_window |
||
63 | jmp dexit |
||
64 | key: |
||
65 | button: |
||
66 | |||
67 | exit: |
||
68 | close |
||
69 | |||
70 | err_exit: |
||
71 | push eax |
||
72 | call draw_window |
||
73 | pop eax |
||
134 | diamond | 74 | ; jmp copy_error |
31 | halyavin | 75 | |
76 | ; print message now |
||
77 | copy_error: |
||
134 | diamond | 78 | imul ebp, eax, 43 |
31 | halyavin | 79 | |
80 | mov eax,4 |
||
81 | mov ebx,20*65536+70 |
||
82 | mov ecx,0x10ff0000 |
||
134 | diamond | 83 | lea edx,[errors+ebp] |
31 | halyavin | 84 | mov esi,43 ;[errors+edi*8+4] |
85 | int 0x40 |
||
86 | jmp dexit |
||
87 | |||
88 | ;closep: |
||
89 | ; or eax,-1 ; close program |
||
90 | ; int 0x40 |
||
91 | |||
92 | |||
93 | ;==================================================== |
||
94 | ; copy_file |
||
95 | ; This piece of code copies src file to dst file, |
||
96 | ; then it pass the control to copy_error routine, |
||
97 | ; which returns to the main cycle of the app. |
||
98 | ; It's NOT a function! It's reached by direct jump |
||
99 | ; from the button handler. |
||
100 | ;==================================================== |
||
101 | copy_file: |
||
102 | ; at first we must get the size of the source file |
||
134 | diamond | 103 | mov dword [source_attr+32], 0 |
104 | mov eax, 70 |
||
105 | mov ebx, source_attr_info |
||
106 | int 0x40 |
||
31 | halyavin | 107 | |
108 | ; now eax contains error code |
||
109 | ; and ebx contains file size in bytes |
||
110 | test eax,eax ; check if eax is equal to zero (success) |
||
111 | je .ok_getsize ; eax = 0 => continue |
||
112 | cmp eax,6 |
||
113 | jna @f |
||
114 | mov eax,7 ; if error code is above 6, it will be 7 |
||
115 | @@: |
||
116 | cmp eax,5 ; file might be copied successfully altrough |
||
117 | ; the system reports an error 5 |
||
118 | jne copy_error ; print error code now |
||
119 | .ok_getsize: |
||
120 | |||
121 | ; allocate memory |
||
134 | diamond | 122 | mov ebx,[source_attr+32] |
31 | halyavin | 123 | push ebx ; save file size |
134 | diamond | 124 | lea ecx,[ebx+0x10000] ; size of memory needed = 0x10000+filesize |
31 | halyavin | 125 | mov eax,64 ; func 64 |
126 | mov ebx,1 ; resize application memory |
||
127 | int 0x40 |
||
128 | pop ebx ; restore filesize |
||
129 | |||
130 | ; check if alloc function failed |
||
131 | test eax,eax ; non-zero value means error |
||
132 | je .ok_memory |
||
133 | mov eax,5 ; error 5 - out of memory |
||
134 | jmp copy_error ; print error code now |
||
135 | .ok_memory: |
||
136 | |||
137 | ; save number of blocks to source_info |
||
134 | diamond | 138 | mov [source_info.bytes], ebx |
31 | halyavin | 139 | ; read the source file |
134 | diamond | 140 | mov eax,70 |
31 | halyavin | 141 | mov ebx,source_info |
142 | int 0x40 |
||
143 | |||
134 | diamond | 144 | ; ebx = number of read bytes = file size |
31 | halyavin | 145 | ; save loaded file |
134 | diamond | 146 | mov [dest_info.bytes],ebx ; file size in bytes |
147 | mov eax,70 |
||
31 | halyavin | 148 | mov ebx,dest_info |
149 | int 0x40 |
||
150 | |||
151 | ; check if 58 function failed |
||
152 | test eax,eax |
||
153 | je .ok_write |
||
154 | add eax,7 ; error number += 7 |
||
155 | cmp eax,6+7 |
||
156 | jna copy_error |
||
157 | mov eax,7+7 |
||
158 | jmp copy_error |
||
159 | .ok_write: |
||
160 | |||
161 | ; return to the initial amount of memory |
||
162 | mov eax,64 |
||
163 | mov ebx,1 |
||
134 | diamond | 164 | mov ecx,0x10000 |
31 | halyavin | 165 | int 0x40 |
166 | |||
167 | xor eax,eax ; eax = message number (0-OK) |
||
134 | diamond | 168 | jmp copy_error |
31 | halyavin | 169 | |
170 | |||
171 | ; ********************************************* |
||
172 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
173 | ; ********************************************* |
||
174 | |||
175 | |||
176 | draw_window: |
||
177 | |||
178 | mov eax,12 ; function 12:tell os about windowdraw |
||
179 | mov ebx,1 ; 1, start of draw |
||
180 | int 0x40 |
||
181 | |||
182 | ; DRAW WINDOW |
||
183 | xor eax,eax ; function 0 : define and draw window |
||
184 | mov ebx,160*65536+415 ; [x start] *65536 + [x size] |
||
185 | mov ecx,160*65536+90 ; [y start] *65536 + [y size] |
||
186 | mov edx,0x03DDDDDD ; color of work area RRGGBB |
||
187 | int 0x40 |
||
188 | |||
189 | ; WINDOW LABEL |
||
190 | mov eax,4 ; function 4 : write text to window |
||
191 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
||
192 | mov ecx,0x10ffffff ; color of text RRGGBB |
||
193 | mov edx,labelt ; pointer to text beginning |
||
194 | mov esi,labellen-labelt ; text length |
||
195 | int 0x40 |
||
196 | |||
197 | mov eax,8 |
||
198 | mov ebx,105*65536+290 |
||
199 | mov ecx,33*65536+12 |
||
200 | mov edx,4 |
||
201 | mov esi,0xEBEBEB |
||
202 | int 0x40 |
||
203 | mov ebx,105*65536+290 |
||
204 | mov ecx,49*65536+12 |
||
205 | mov edx,5 |
||
206 | mov esi,0xEBEBEB |
||
207 | int 0x40 |
||
208 | |||
209 | mov esi,source |
||
210 | mov edi,text+14 |
||
134 | diamond | 211 | mov ecx,47 |
31 | halyavin | 212 | rep movsb |
213 | |||
214 | mov esi,destination |
||
134 | diamond | 215 | mov edi,text+62+14 |
216 | mov ecx,47 |
||
31 | halyavin | 217 | rep movsb |
218 | |||
219 | mov ebx,25*65536+36 ; print filenames |
||
220 | xor ecx,ecx |
||
221 | mov edx,text |
||
134 | diamond | 222 | mov esi,62 |
31 | halyavin | 223 | newline: |
224 | mov eax,4 |
||
225 | int 0x40 |
||
226 | add ebx,16 |
||
134 | diamond | 227 | add edx,62 |
31 | halyavin | 228 | cmp [edx],byte 'x' |
229 | jnz newline |
||
230 | |||
231 | mov eax,12 ; function 12:tell os about windowdraw |
||
232 | mov ebx,2 ; 2, end of draw |
||
233 | int 0x40 |
||
234 | |||
235 | ret |
||
236 | |||
237 | |||
238 | ; DATA AREA |
||
239 | |||
240 | align 4 |
||
241 | addr dd 0x0 |
||
242 | ya dd 0x0 |
||
243 | temp dd 0 |
||
244 | |||
134 | diamond | 245 | if lang eq ru |
31 | halyavin | 246 | text: |
247 | db ' ОТКУДА: |Россия, Селятино, МПК Москва , 1 Курс ' |
||
248 | db ' КУДА: | Павлюшин Евгений, waptap@mail.ru ' |
||
249 | db ' ' |
||
250 | db 'x' ; <- END MARKER, DONT DELETE |
||
251 | labelt: |
||
134 | diamond | 252 | db 'КОПИРОВАНИЕ ФАЙЛА' |
31 | halyavin | 253 | labellen: |
254 | |||
255 | errors: |
||
256 | db "файл скопирован успешно " |
||
257 | db "(чтение) не задана база жд " |
||
258 | db "(чтение) файловая система не поддерживается" |
||
259 | db "(чтение) неизвестная файловая система " |
||
260 | db "(чтение) не задан раздел жд " |
||
261 | db "недостаточно памяти " |
||
262 | db "(чтение) конец файла " |
||
263 | db "(чтение) неизвестная ошибка " |
||
264 | db "(запись) не задан раздел жд " |
||
265 | db "(запись) файловая система не поддерживается" |
||
266 | db "(запись) неизвестная файловая система " |
||
267 | db "(запись) не задан раздел жд " |
||
268 | db "oh shit! " |
||
269 | db "(запись) файл не найден " |
||
270 | db "(запись) неизвестная ошибка " |
||
271 | db "Путь к источнику и приемнику не указаны!!! " |
||
272 | db "Путь к приемнику не указан!!! " |
||
134 | diamond | 273 | else |
274 | text: |
||
275 | db 'SOURCE: | ' |
||
276 | db 'DESTINATION: | ' |
||
277 | db ' ' |
||
278 | db 'x' ; <- END MARKER, DONT DELETE |
||
279 | labelt: |
||
280 | db 'SYSTREE FILE COPIER' |
||
281 | labellen: |
||
31 | halyavin | 282 | |
134 | diamond | 283 | errors: |
284 | db "Success! " |
||
285 | db "(read) no hd base or partition defined " |
||
286 | db "(read) unsupported file system " |
||
287 | db "(read) unknown file system " |
||
288 | db "(read) hd partition not defined " |
||
289 | db "out of memory " |
||
290 | db "(read) end of file " |
||
291 | db "(read) unknown error " |
||
292 | db "(write) no hd base or partition defined " |
||
293 | db "(write) unsupported file system " |
||
294 | db "(write) unknown file system " |
||
295 | db "(write) hd partition not defined " |
||
296 | db "oh shit! " |
||
297 | db "(write) file not found " |
||
298 | db "(write) unknown error " |
||
299 | db "Path to source is not given!!! " |
||
300 | db "Path to destination is not given!!! " |
||
301 | end if |
||
302 | |||
31 | halyavin | 303 | ;0123456789012345678901234567890123456789012 |
134 | diamond | 304 | |
305 | source_attr_info: |
||
306 | dd 5 |
||
307 | dd 0 |
||
308 | dd 0 |
||
309 | dd 0 |
||
310 | dd source_attr |
||
311 | db 0 |
||
312 | dd source |
||
313 | |||
314 | source_info: |
||
315 | dd 0 |
||
316 | dd 0 ; start from 1st byte |
||
317 | dd 0 |
||
318 | .bytes dd ? |
||
319 | dd 0x10000 |
||
320 | db 0 |
||
321 | dd source |
||
322 | |||
323 | dest_info: ; DESTINATION FILEINFO |
||
324 | dd 2 |
||
325 | dd 0 |
||
326 | dd 0 |
||
327 | .bytes dd ? |
||
328 | dd 0x10000 |
||
329 | |||
330 | I_END: |
||
331 | |||
332 | destination: |
||
333 | rb 256 |
||
334 | source: |
||
335 | rb 256 |
||
336 | source_attr: |
||
337 | rb 40 |
||
338 | |||
339 | param_area rb 256->-> |