Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 193 → Rev 183

/programs/fs/copy2/trunk/copy2.asm
1,7 → 1,4
; project name: SYSTREE FILE COPIER
; version: 1.2
; Mario79 23/10/06
;
; version: 1.1b
; last update: 18/07/2004
; compiler: FASM 1.52
10,7 → 7,6
; copying-policy: GPL
 
; History:
; 23/10/06 application use function 70
; 18/07/2004 strings using "lsz" macro + french language (not 100%!)
; 04/06/2004 Bugfix for memory - thanks to Ville
; ...
22,7 → 18,7
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x10000 ; memory for app
dd 0x20201 ; memory for app
dd 0x10000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
73,11 → 69,11
jnz still
 
srcbtn:
mov [addr],dword source_info.name ;source
mov [addr],dword source
mov [ya],dword 36
jmp rk
dstbtn:
mov [addr],dword dest_info.name ;destination
mov [addr],dword destination
mov [ya],dword 36+16
 
rk:
154,18 → 150,32
;====================================================
copy_file:
; at first we must get the size of the source file
mcall 70, get_param_info
mov [source_info.blocks],1 ; load only 512 bytes
mov eax,58
mov ebx,source_info
int 0x40
 
; now eax contains error code
; and ebx contains file size in bytes
test eax,eax ; check if eax is equal to zero (success)
je .ok_getsize ; eax = 0 => continue
cmp eax,6
jna @f
mov eax,7 ; if error code is above 6, it will be 7
@@:
cmp eax,5 ; file might be copied successfully altrough
; the system reports an error 5
jne copy_error ; print error code now
.ok_getsize:
 
; allocate memory
mov ecx,[param_info+32] ;ebx
add ecx,0x10000 ; size of memory needed = 0x10000+filesize
push ebx ; save file size
mov ecx,ebx
add ecx,0x20000 ; size of memory needed = 0x20000+filesize
mov eax,64 ; func 64
mov ebx,1 ; resize application memory
int 0x40
pop ebx ; restore filesize
 
; check if alloc function failed
test eax,eax ; non-zero value means error
174,29 → 184,36
jmp copy_error ; print error code now
.ok_memory:
 
; save size to source_info
mov ebx,[param_info+32]
mov [source_info.size],ebx ; read the source file
mcall 70,source_info
; save number of blocks to source_info
add ebx,511
shr ebx,9 ; round up to 512 boundary
mov [source_info.blocks],ebx
; read the source file
mov eax,58
mov ebx,source_info
int 0x40
 
; now eax contains error code
test eax,eax ; check if eax is equal to zero (success)
jne copy_error ; print error code now
 
; file size in bytes
mov [dest_info.size],ebx
 
; ebx = file size
; save loaded file
mcall 70,dest_info
mov [dest_info.bytes2write],ebx ; file size in bytes
mov eax,58
mov ebx,dest_info
int 0x40
 
; now eax contains error code
; check if 58 function failed
test eax,eax
jne copy_error
je .ok_write
add eax,7 ; error number += 7
cmp eax,6+7
jna copy_error
mov eax,7+7
jmp copy_error
.ok_write:
 
; return to the initial amount of memory
mov eax,64
mov ebx,1
mov ecx,0x10000
mov ecx,0x20201
int 0x40
 
xor eax,eax ; eax = message number (0-OK)
280,12 → 297,12
mov esi, 0xEBEBEB
int 0x40
 
mov esi, source_info.name ;source
mov esi, source
mov edi, text+14
mov ecx, STRLEN
rep movsb
 
mov esi, dest_info.name ;destination
mov esi, destination
mov edi, text+STRLEN+59-45+14
mov ecx, STRLEN
rep movsb
310,59 → 327,25
 
 
; DATA AREA
get_param_info:
.subfunction dd 5 ; 5 - get parameters of file
.start dd 0 ; rezerved
.size_high dd 0 ; rezerved
.size dd 0 ; rezerved
.return dd param_info
.name:
db 0
dd source_info.name
 
align 4
source_info: ; SOURCE FILEINFO
.subfunction dd 0 ; 0=READ
.start dd 0
.size_high dd 0
.size dd 0
.return dd 0x10000
.name:
db '/hd0/1/kernel/kernel.mnt',0 ; ASCIIZ dir & filename
times (STRLEN-24) db 0
.mode dd 0 ; read file
.start_block dd 0x0 ; block to read
.blocks dd 0x700 ; num of blocks
.address dd 0x20000
.workarea dd 0x10000
source db '/HD/1/KERNEL/KERNEL.MNT',0
times (STRLEN-23) db 0
 
dest_info: ; DESTINATION FILEINFO
.subfunction dd 2 ; 0=WRITE
.start dd 0
.size_high dd 0
.size dd 0
.return dd 0x10000
.name:
db '/rd/1/kernel.mnt',0 ; ASCIIZ dir & filename
.mode dd 1 ; write
.notused dd 0x0 ; not used
.bytes2write dd 0 ; bytes to write
.address dd 0x20000
.workarea dd 0x10000
destination db '/RD/1/KERNEL.MNT',0
times (STRLEN-16) db 0
 
param_info:
rb 40
 
 
;align 4
;source_info: ; SOURCE FILEINFO
; .mode dd 0 ; read file
; .start_block dd 0x0 ; block to read
; .blocks dd 0x700 ; num of blocks
; .address dd 0x20000
; .workarea dd 0x10000
; source db '/HD/1/KERNEL/KERNEL.MNT',0
; times (STRLEN-23) db 0
;
;dest_info: ; DESTINATION FILEINFO
; .mode dd 1 ; write
; .notused dd 0x0 ; not used
; .bytes2write dd 0 ; bytes to write
; .address dd 0x20000
; .workarea dd 0x10000
; destination db '/RD/1/KERNEL.MNT',0
; times (STRLEN-16) db 0
 
align 4
addr dd 0x0
ya dd 0x0