A2osX/BIN/X.CPLSMVRM.S.txt
2016-10-24 17:54:43 +02:00

179 lines
3.0 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* Uses: (pData)
* hDIRs .BS MAX.RECURSE+1
* hBasePath .BS 1
*--------------------------------------
InitSrcDirYA >SYSCALL GetFullPathYA
bcc .10
rts
.10 stx .90+1
>STYA ZPPtr1
lda (ZPPtr1)
cmp #1
beq .5 we have '/'
>PUSHW L.STAT
>PUSHW ZPPtr1
>SYSCALL STAT
bcs .1 File/DIR does not exists, go extract wildcard
lda STAT+S.STAT.PRODOS.TYPE
cmp #$0f
beq .5 TYPE=DIR, do not extract wildcard
.1 lda (ZPPtr1)
tay
.2 lda (ZPPtr1),y search backward for a /
cmp #'/'
beq .3
dey
bne .2
.3 tya
cmp (ZPPtr1)
beq .5 Make sure at least one char
ldx #0
phy save / pos to trunk string later
.4 iny
inx
lda (ZPPtr1),y
sta UsrBuf256,x
tya
cmp (ZPPtr1)
bne .4
pla get back / pos
sta (ZPPtr1) trunk it for Opendir
stx UsrBuf256
>LDYAI UsrBuf256
>SYSCALL NewPstrYA
bcs .9
txa
ldy #hFilter
sta (pData),y
.5 >PUSHWI 256
>PUSHBI 0
>SYSCALL GetMem Get a 256 buffer to store BasePath
bcs .9
>STYA ZPPtr2
txa
ldy #hBasePath
sta (pData),y
>PUSHW ZPPtr1 Push Src
>PUSHW ZPPtr2 Push Dst
>SYSCALL PStrCpy
>LDYA ZPPtr1
>SYSCALL OPENDIRYA
bcs .9
pha
ldy #hDIRs
tya
inc
sta (pData),y
iny set hDIRs[1] = Src Hdir
pla
sta (pData),y set hDIRs index=hDIRs[1]
jsr .9 Cleanup
clc
rts
.9 pha
.90 lda #$ff self modified
>SYSCALL FreeMemA
pla
sec
rts
*--------------------------------------
EnterSubDirYA >STYA ZPPtr2 save SUBDIR for StrCat
ldy #hDIRs
lda (pData),y
cmp #hDIRs+MAX.RECURSE+1
beq .99
ldy #hBasePath
lda (pData),y
>SYSCALL GetMemPtrA
>STYA ZPPtr1 save full path
>PUSHW ZPPtr1 push Src for StrCat
>PUSHW ZPPtr2
>SYSCALL PStrCat
>LDYA ZPPtr1
>SYSCALL OPENDIRYA
bcs .99
pha
ldy #hDIRs
lda (pData),y
inc
sta (pData),y
tay
pla
sta (pData),y
clc
.99 rts
*--------------------------------------
LeaveSubDir ldy #hDIRs
lda (pData),y
tay
lda (pData),y
>SYSCALL CLOSEDIRA
ldy #hBasePath
lda (pData),y
>SYSCALL GetMemPtrA
>STYA ZPPtr1 save full path
lda (ZPPtr1) get len
tay
.1 dey At first run, discard ending /
lda (ZPPtr1),y
cmp #'/'
bne .1
tya
sta (ZPPtr1) cut DIR2/ from /dir1/DIR2/
ldy #hDIRs
lda (pData),y
dec
sta (pData),y
cmp #hDIRs
beq .9 CS
clc
.9 rts
*--------------------------------------
MAN
SAVE BIN/X.CPLSMVRM.S