Subversion Repositories Kolibri OS

Rev

Rev 503 | 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.     mcall
  86.     jmp dexit
  87.  
  88. ;closep:
  89. ;    or   eax,-1        ; close program
  90. ;    mcall
  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.     mcall
  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.     mcall
  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.     mcall
  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.     mcall
  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.     mcall
  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,0x14DDDDDD            ; color of work area RRGGBB
  187.     mov  edi,labelt                ; WINDOW LABEL
  188.     mcall
  189.  
  190.                                    
  191.     mov  eax,8
  192.     mov  ebx,105*65536+290
  193.     mov  ecx,33*65536+12
  194.     mov  edx,4
  195.     mov  esi,0xEBEBEB
  196.     mcall
  197.     mov  ebx,105*65536+290
  198.     mov  ecx,49*65536+12
  199.     mov  edx,5
  200.     mov  esi,0xEBEBEB
  201.     mcall
  202.  
  203.     mov  esi,source
  204.     mov  edi,text+14
  205.     mov  ecx,47
  206.     rep  movsb
  207.  
  208.     mov  esi,destination
  209.     mov  edi,text+62+14
  210.     mov  ecx,47
  211.     rep  movsb
  212.  
  213.     mov  ebx,25*65536+36   ; print filenames
  214.     xor  ecx,ecx
  215.     mov  edx,text
  216.     mov  esi,62
  217.     mov  eax,4
  218.   newline:
  219.     mcall
  220.     add  ebx,16
  221.     add  edx,62
  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
  227.     mcall
  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.  
  239. if lang eq ru
  240. text:
  241.       db '   Ž’Š“„€:    |®áá¨ï, ‘¥«ï⨭®, ŒŠ Œ®áª¢   , 1 Šãàá         '
  242.       db '    Š“„€:     |         ¢«î設 …¢£¥­¨©, waptap@mail.ru       '
  243.       db '                                                              '
  244.       db 'x' ; <- END MARKER, DONT DELETE
  245.  
  246. labelt:
  247.       db   'ŠŽˆŽ‚€ˆ… ”€‰‹€',0
  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     "ãâì ª ¯à¨¥¬­¨ªã ­¥ 㪠§ ­!!!              "
  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:
  276.  
  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.  
  297.          ;0123456789012345678901234567890123456789012
  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
  334.