home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 57
/
Amiga_Dream_57.iso
/
Amiga
/
Programmation
/
Assembleur
/
ESA.lha
/
ESA
/
examples
/
sss
/
split.ei
< prev
next >
Wrap
Text File
|
1998-10-30
|
2KB
|
74 lines
*******************************************************************************
* Split v1.0.0
*******************************************************************************
* INFO program core
* SYNOPSIS Split[]
* MODIFIES d0 0=OK, else E_xxxxxx (see defs.i)
* REQUIRES _DOSBase dos.library ptr
*******************************************************************************
procedure Split[],d1-d7/a0-a2/a6
movea.l _DOSBase,a6
moveq.l #0,d7 ;chunk counter
moveq.l #0,d5 ;no error
move.l InFileSze,d4 ;source file size
repeat
Stru[d7,ExtnAdr,DgtNmb] ;build extension
Print[#txt_writing] ;a0 already saved
Print[#OutBase] ;show current chunk name
move.l #OutBase,d1 ;open new dest file
move.l #MODE_NEWFILE,d2
jsr (_LVOOpen,a6)
movea.l d0,a2 ;store filehandle
when d0.l ;if file opened successfully
move.l ChnkSize,d6 ;bytes to read
when.s d4½d6 ;if not enough bytes left
move.l d4,d6 ;read all remaining ones
ewhen
sub.l d6,d4 ;bytes left
repeat
move.l InFileHnd,d1 ;source filehandle
move.l WrkBufAdr,d2 ;dest buf
when.s d6╗=WrkBufLen
move.l WrkBufLen,d3 ;fill the work buf
othw
move.l d6,d3 ;read only necessary data
ewhen
jsr (_LVORead,a6)
sub.l d0,d6 ;update bytes to write
move.l a2,d1 ;dest filehandle
move.l WrkBufAdr,d2 ;buf
move.l d0,d3 ;write bytes read to dest
jsr (_LVOWrite,a6)
when.s d0<d3 ;if not all bytes written
moveq.l #E_DSTFLE,d5 ;give error
ewhen ;('<' cos d0 could be -1)
until ~d6.l | d5 ;exit if buf completely written
;or error on writing
othw
moveq.l #E_DSTFLE,d5 ;error opening dest!
exit ;exit repeat...until
ewhen
move.l a2,d1 ;close dest file
jsr (_LVOClose,a6)
addq.l #1,d7 ;next chunk
until {d7.l╗MaxChnk} | d5 ;exit if chunks over
;or error on writing
Print[#txt_ENTER]
move.l d5,d0 ;ErrCode
eproc