A2osX/BIN/X.CPLSMVRM.S.txt
2016-10-19 17:47:53 +02:00

137 lines
2.5 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
*--------------------------------------
SetSrcDirYA >SYSCALL SYS.GetFullPathYA
bcs .99
stx .90+1
>STYA ZPPtr1
lda (ZPPtr1)
cmp #1
beq .5 we have '/'
>PUSHW L.STAT
>PUSHW ZPPtr1
>SYSCALL SYS.STAT
bcs .1 File/DIR does not exists, go extract wildcard
lda STAT+S.STAT.PRODOS.TYPE
cmp #$0f
beq .7 TYPE=DIR, do not estract wildcard
.1 lda (ZPPtr1)
tay
.2 lda (ZPPtr1),y search backward for a /
cmp #'/'
beq .3
dey
bne .2
.3 tya
cmp (ZPPtr1)
beq .7 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 SYS.NewPstrYA
bcs .9
txa
ldy #hFilter
sta (pData),y
.5 >PUSHWI 256
>PUSHBI 0
>SYSCALL SYS.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 SYS.PStrCpy
>LDYA ZPPtr1
>SYSCALL SYS.OPENDIRYA
bcs .9
ldy #hDIRs
sta (pData),y set hDIRs[1] = Src Hdir
tya
sta (pData),y set hDIRs index=hDIRs[1]
jsr .9 Cleanup
clc
.99 rts
.9 pha
.90 lda #$ff self modified
>SYSCALL SYS.FreeMemA
pla
sec
rts
*--------------------------------------
EnterDirYA >PUSHYA push Src for StrCat
ldy #hBasePath
lda (pData),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPPtr1 save full path
>PUSHYA push Src for StrCat
>SYSCALL SYS.StrCat
jsr GetNextDir
beq .99 CS
clc
.99 rts
*--------------------------------------
LeaveDir
*--------------------------------------
GetNextDir ldy #hDIRs
lda (pData),y
cmp #hDIRs+MAX.RECURSE+1
beq .99 CS full!!! all hDIRs already alloacated
inc
clc
.99 rts
*--------------------------------------
GetLastDir
*--------------------------------------
MAN
SAVE BIN/X.CPLSMVRM.S.txt