Subversion Repositories Kolibri OS

Rev

Rev 503 | 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'
485 heavyiron 27
include '..\..\..\macros.inc'       ; very useful stuff for MeOS
31 halyavin 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]
485 heavyiron 85
    mcall
31 halyavin 86
    jmp dexit
87
 
88
;closep:
89
;    or   eax,-1        ; close program
485 heavyiron 90
;    mcall
31 halyavin 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
485 heavyiron 127
    mcall
31 halyavin 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
485 heavyiron 142
    mcall
31 halyavin 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
485 heavyiron 149
    mcall
31 halyavin 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
485 heavyiron 165
    mcall
31 halyavin 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
485 heavyiron 180
    mcall
31 halyavin 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]
503 heavyiron 185
    mov  ecx,160*65536+90          ; [y start] *65536 + [y size]
551 spraid 186
    mov  edx,0x14DDDDDD            ; color of work area RRGGBB
503 heavyiron 187
    mov  edi,labelt                ; WINDOW LABEL
485 heavyiron 188
    mcall
31 halyavin 189
 
503 heavyiron 190
 
31 halyavin 191
    mov  eax,8
192
    mov  ebx,105*65536+290
193
    mov  ecx,33*65536+12
194
    mov  edx,4
195
    mov  esi,0xEBEBEB
485 heavyiron 196
    mcall
31 halyavin 197
    mov  ebx,105*65536+290
198
    mov  ecx,49*65536+12
199
    mov  edx,5
200
    mov  esi,0xEBEBEB
485 heavyiron 201
    mcall
31 halyavin 202
 
203
    mov  esi,source
204
    mov  edi,text+14
134 diamond 205
    mov  ecx,47
31 halyavin 206
    rep  movsb
207
 
208
    mov  esi,destination
134 diamond 209
    mov  edi,text+62+14
210
    mov  ecx,47
31 halyavin 211
    rep  movsb
212
 
213
    mov  ebx,25*65536+36   ; print filenames
214
    xor  ecx,ecx
215
    mov  edx,text
134 diamond 216
    mov  esi,62
503 heavyiron 217
    mov  eax,4
31 halyavin 218
  newline:
485 heavyiron 219
    mcall
31 halyavin 220
    add  ebx,16
134 diamond 221
    add  edx,62
31 halyavin 222
    cmp  [edx],byte 'x'
223
    jnz  newline
224
 
225
    mov  eax,12                    ; function 12:tell os about windowdraw
226
    mov  ebx,2                     ; 2, end of draw
485 heavyiron 227
    mcall
31 halyavin 228
 
229
    ret
230
 
231
 
232
; DATA AREA
233
 
234
  align 4
235
  addr  dd  0x0
236
  ya    dd  0x0
237
  temp  dd  0
238
 
134 diamond 239
if lang eq ru
31 halyavin 240
text:
241
      db '   ОТКУДА:    |Россия, Селятино, МПК Москва  , 1 Курс         '
242
      db '    КУДА:     |        Павлюшин Евгений, waptap@mail.ru       '
243
      db '                                                              '
244
      db 'x' ; <- END MARKER, DONT DELETE
503 heavyiron 245
 
31 halyavin 246
labelt:
503 heavyiron 247
      db   'КОПИРОВАНИЕ ФАЙЛА',0
31 halyavin 248
 
249
errors:
250
  db     "файл скопирован успешно                    "
251
  db     "(чтение) не задана база жд                 "
252
  db     "(чтение) файловая система не поддерживается"
253
  db     "(чтение) неизвестная файловая система      "
254
  db     "(чтение) не задан раздел жд                "
255
  db     "недостаточно памяти                        "
256
  db     "(чтение) конец файла                       "
257
  db     "(чтение) неизвестная ошибка                "
258
  db     "(запись) не задан раздел жд                "
259
  db     "(запись) файловая система не поддерживается"
260
  db     "(запись) неизвестная файловая система      "
261
  db     "(запись) не задан раздел жд                "
262
  db     "oh shit!                                   "
263
  db     "(запись) файл не найден                    "
264
  db     "(запись) неизвестная ошибка                "
265
  db     "Путь к источнику и приемнику не указаны!!! "
266
  db     "Путь к приемнику не указан!!!              "
134 diamond 267
else
268
text:
269
      db 'SOURCE:       |                                               '
270
      db 'DESTINATION:  |                                               '
271
      db '                                                              '
272
      db 'x' ; <- END MARKER, DONT DELETE
273
labelt:
274
      db   'SYSTREE FILE COPIER'
275
labellen:
31 halyavin 276
 
134 diamond 277
errors:
278
  db     "Success!                                   "
279
  db     "(read) no hd base or partition defined     "
280
  db     "(read) unsupported file system             "
281
  db     "(read) unknown file system                 "
282
  db     "(read) hd partition not defined            "
283
  db     "out of memory                              "
284
  db     "(read) end of file                         "
285
  db     "(read) unknown error                       "
286
  db     "(write) no hd base or partition defined    "
287
  db     "(write) unsupported file system            "
288
  db     "(write) unknown file system                "
289
  db     "(write) hd partition not defined           "
290
  db     "oh shit!                                   "
291
  db     "(write) file not found                     "
292
  db     "(write) unknown error                      "
293
  db     "Path to source is not given!!!             "
294
  db     "Path to destination is not given!!!        "
295
end if
296
 
31 halyavin 297
         ;0123456789012345678901234567890123456789012
134 diamond 298
 
299
source_attr_info:
300
        dd      5
301
        dd      0
302
        dd      0
303
        dd      0
304
        dd      source_attr
305
        db      0
306
        dd      source
307
 
308
source_info:
309
        dd      0
310
        dd      0       ; start from 1st byte
311
        dd      0
312
.bytes  dd      ?
313
        dd      0x10000
314
        db      0
315
        dd      source
316
 
317
dest_info:                   ; DESTINATION FILEINFO
318
        dd      2
319
        dd      0
320
        dd      0
321
.bytes  dd      ?
322
        dd      0x10000
323
 
324
I_END:
325
 
326
destination:
327
        rb      256
328
source:
329
        rb      256
330
source_attr:
331
        rb      40
332
 
333
param_area      rb      256