A2osX/BIN/X.CPLSMVRM.S.txt
Rémy GIBERT ce34b41f47 ENH #7 : Added -A switch to LS
(revealed many bugs in LS.S & KERNEL.S.CIO.txt that are now corrected)
2016-10-28 11:37:57 +02:00

314 lines
5.2 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
ldy #hDIRs
sta (pData),y set hDIRs[0] = Src Hdir
ldy #index
lda #1
sta (pData),y index=hDIRs[0]
jsr .9 Cleanup
clc
rts
.9 pha
.90 lda #$ff self modified
>SYSCALL FreeMemA
pla
sec
InitSrcDirYA.RTS
rts
*--------------------------------------
GetNextEntry ldy #index
lda (pData),y
tax keep index for later
clc
adc #hDIRENTs-1
tay
lda (pData),y
bne .1 we have a buffer to scan
txa get back index....
clc
adc #hDIRs-1
tay
lda (pData),y
>SYSCALL ReadDirA
bcs InitSrcDirYA.RTS
>STYA ZPPtr1
ldy #index
lda (pData),y
pha save index for later
clc
adc #hDIRENTs-1
tay
txa get hDIRENT in A
sta (pData),y
pla get back index
asl
adc #oDIRENTs-1 and reset offset for this buffer
tay
lda #0
sta (pData),y
iny
sta (pData),y
bra .2
.1 >SYSCALL GetMemPtrA
>STYA ZPPtr1
ldy #index
lda (pData),y
asl
adc #oDIRENTs-1 CC from ASL
tay
lda ZPPtr1
* clc from ADC
adc (pData),y
sta ZPPtr1
lda ZPPtr1+1
iny
adc (pData),y
sta ZPPtr1+1
.2 lda (ZPPtr1) first/next DIRENT
bne .8
sta (pData),y reset offset...
dey
sta (pData),y
ldy #index
lda (pData),y
clc
adc #hDIRENTs-1
tay
lda (pData),y
pha
lda #0
sta (pData),y reset hDIRENT
pla
>SYSCALL FreeMemA discard hDIRENT
bra GetNextEntry ...startover
.8 ldy #index
lda (pData),y
asl
adc #oDIRENTs-1
tay
lda (ZPPtr1) Add file len+1...
sec
adc #S.STAT +S.STAT
* clc from ADC
adc (pData),y Make oDIRENTs[i] point to next DIRENT
sta (pData),y
iny
lda (pData),y
adc #0
sta (pData),y
lda ZPPtr1 set Ptr2=Ptr1+LEN-> S.STAT
sec
adc (ZPPtr1)
sta ZPPtr2
lda ZPPtr1+1
adc #0
sta ZPPtr2+1
clc
rts
*--------------------------------------
EnterSubDirYA >STYA ZPPtr2 save SUBDIR for StrCat
ldy #index
lda (pData),y
cmp #MAX.RECURSE
beq .9
ldy #hBasePath
lda (pData),y
>SYSCALL GetMemPtrA
>STYA ZPPtr1 save full path
>PUSHW ZPPtr2
>PUSHW ZPPtr1
>SYSCALL PStrCat
lda (ZPPtr1)
inc
tay
sta (ZPPtr1)
lda #'/'
sta (ZPPtr1),y
>PUSHW ZPPtr1
>LDYA L.MSG.ENTER
>SYSCALL PrintFYA
>LDYA ZPPtr1
>SYSCALL OpenDirYA
bcs .9
pha
ldy #index
lda (pData),y
inc
sta (pData),y
tax
* clc from BCS
adc #hDIRs-1
tay
pla
sta (pData),y
txa make sure hDIRENTs[i] is closed
adc #hDIRENTs-1
tay
lda #0
sta (pData),y
.9 rts
*--------------------------------------
LeaveSubDir ldy #index
lda (pData),y
beq .9
clc
adc #hDIRs-1
tay
lda (pData),y
pha
lda #0
sta (pData),y
pla
>SYSCALL CloseDirA
ldy #index
lda (pData),y
dec
sta (pData),y
beq .9
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/
clc
rts
.9 sec
rts
*--------------------------------------
MAN
SAVE BIN/X.CPLSMVRM.S
LOAD BIN/LS.S
ASM