Subversion Repositories Kolibri OS

Rev

Rev 134 | Rev 485 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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           ;
  11. ;                                           ;
  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
  22.     dd      0x10000        ; memory for app
  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. ;  à ¬¥âàë:
  33. ; db n1 = ¤«¨­  ¯ã⨠ª ¨áâ®ç­¨ªã
  34. ; times n1 db ? = ¯ãâì ª ¨áâ®ç­¨ªã
  35. ; db n2 = ¤«¨­  ¯ã⨠ª ¯à¨ñ¬­¨ªã
  36. ; times n2 db ? = ¯ãâì ª ¯à¨ñ¬­¨ªã
  37. ; db 0
  38.  
  39. ;get param
  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
  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
  74. ;    jmp copy_error
  75.  
  76. ; print message now
  77. copy_error:
  78.         imul    ebp, eax, 43
  79.  
  80.     mov  eax,4
  81.     mov  ebx,20*65536+70
  82.     mov  ecx,0x10ff0000
  83.     lea  edx,[errors+ebp]
  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
  103.         mov     dword [source_attr+32], 0
  104.         mov     eax, 70
  105.         mov     ebx, source_attr_info
  106.         int     0x40
  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
  122.     mov  ebx,[source_attr+32]
  123.     push ebx         ; save file size
  124.     lea  ecx,[ebx+0x10000] ; size of memory needed = 0x10000+filesize
  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
  138.         mov     [source_info.bytes], ebx
  139.     ; read the source file
  140.     mov  eax,70
  141.     mov  ebx,source_info
  142.     int  0x40
  143.  
  144.     ; ebx = number of read bytes = file size
  145.     ; save loaded file
  146.     mov  [dest_info.bytes],ebx ; file size in bytes
  147.     mov  eax,70
  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
  164.     mov  ecx,0x10000
  165.     int  0x40
  166.  
  167.     xor  eax,eax      ; eax = message number (0-OK)
  168.     jmp  copy_error
  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
  211.     mov  ecx,47
  212.     rep  movsb
  213.  
  214.     mov  esi,destination
  215.     mov  edi,text+62+14
  216.     mov  ecx,47
  217.     rep  movsb
  218.  
  219.     mov  ebx,25*65536+36   ; print filenames
  220.     xor  ecx,ecx
  221.     mov  edx,text
  222.     mov  esi,62
  223.   newline:
  224.     mov  eax,4
  225.     int  0x40
  226.     add  ebx,16
  227.     add  edx,62
  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.  
  245. if lang eq ru
  246. text:
  247.       db '   Ž’Š“„€:    |®áá¨ï, ‘¥«ï⨭®, ŒŠ Œ®áª¢   , 1 Šãàá         '
  248.       db '    Š“„€:     |         ¢«î設 …¢£¥­¨©, waptap@mail.ru       '
  249.       db '                                                              '
  250.       db 'x' ; <- END MARKER, DONT DELETE
  251. labelt:
  252.       db   'ŠŽˆŽ‚€ˆ… ”€‰‹€'
  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     "ãâì ª ¯à¨¥¬­¨ªã ­¥ 㪠§ ­!!!              "
  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:
  282.  
  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.  
  303.          ;0123456789012345678901234567890123456789012
  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
  340.