2016-10-18 06:26:24 +00:00
|
|
|
|
NEW
|
2019-09-19 15:22:14 +00:00
|
|
|
|
AUTO 3,1
|
2021-06-26 20:24:25 +00:00
|
|
|
|
.LIST OFF
|
2016-10-18 06:26:24 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-24 16:34:02 +00:00
|
|
|
|
X.MAX.RECURSE .EQ 8
|
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
* Uses:
|
|
|
|
|
* (ZP)
|
|
|
|
|
* ZPPtr1 .BS 2
|
|
|
|
|
* ZPPtr2 .BS 2
|
|
|
|
|
* ZPFileName .BS 2
|
|
|
|
|
* ZPFileStat .BS 2
|
|
|
|
|
* (pData)
|
2021-06-26 20:24:25 +00:00
|
|
|
|
* Index .BS 1
|
2017-09-22 15:25:21 +00:00
|
|
|
|
* hDIRs .BS X.MAX.RECURSE+1
|
|
|
|
|
* hDIRENTs .BS X.MAX.RECURSE+1
|
2021-06-26 20:24:25 +00:00
|
|
|
|
* oDIRENTs .BS X.MAX.RECURSE*2
|
2021-06-27 13:48:04 +00:00
|
|
|
|
* STATBUF .BS S.STAT
|
2017-09-22 15:25:21 +00:00
|
|
|
|
* hSrcBasePath .BS 1
|
|
|
|
|
* hDstBasePath .BS 1 (optional)
|
2023-02-07 07:04:23 +00:00
|
|
|
|
* hInclude .BS 1
|
2023-07-14 10:24:49 +00:00
|
|
|
|
* hIgnore .BS 1
|
2017-09-22 15:25:21 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
* Compare a ZPFileName against hInclude (e.g. '*test?.*')
|
2018-12-17 15:21:32 +00:00
|
|
|
|
* CC : match
|
|
|
|
|
* CS : no match
|
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.IncludeMatch >LDA.G index
|
2019-04-30 16:08:47 +00:00
|
|
|
|
dec
|
2023-02-07 07:04:23 +00:00
|
|
|
|
bne X.FilterMatch.CLCRTS in a subdir, match everything
|
2019-11-26 21:59:48 +00:00
|
|
|
|
|
2020-02-29 14:06:28 +00:00
|
|
|
|
clc
|
|
|
|
|
.HS B0 BCS
|
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.IgnoreMatch sec
|
|
|
|
|
ldy #hInclude
|
|
|
|
|
bcc .11
|
|
|
|
|
|
2023-07-14 10:24:49 +00:00
|
|
|
|
iny hIgnore
|
2023-02-07 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
.11 lda (pData),y
|
|
|
|
|
beq X.FilterMatch.RTS No filter....exit with passed carry
|
2019-11-26 21:59:48 +00:00
|
|
|
|
|
2019-04-30 16:08:47 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPPtr2
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-11-27 22:04:55 +00:00
|
|
|
|
ldy #S.STAT.FSID
|
2021-08-01 13:45:15 +00:00
|
|
|
|
lda (ZPFileStat),y if 0, Regular ProDOS....
|
2023-02-07 07:04:23 +00:00
|
|
|
|
pha save FSID for comparing later
|
2019-11-29 15:36:54 +00:00
|
|
|
|
bne .10
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2019-11-29 15:36:54 +00:00
|
|
|
|
>LDYA ZPPtr2 ... so CI compare
|
2020-03-03 16:44:52 +00:00
|
|
|
|
>SYSCALL StrUpr
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2021-08-01 13:45:15 +00:00
|
|
|
|
.10 plx get back FSID
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2) Get first pattern byte
|
2021-03-11 21:40:55 +00:00
|
|
|
|
beq .8 Match always if empty
|
2018-12-17 15:21:32 +00:00
|
|
|
|
|
2019-10-12 14:20:09 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
bra .2
|
2018-12-17 15:21:32 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.1 jsr X.FilterMatch.NextPtr2 get next pattern char
|
2018-12-17 15:21:32 +00:00
|
|
|
|
beq .41 end of pattern...
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2021-06-26 20:24:25 +00:00
|
|
|
|
.2 cmp #'*'
|
2018-12-17 15:21:32 +00:00
|
|
|
|
beq .5
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
|
|
|
|
.3 lda (ZPFileName),y we must match ? or regular char, check if at end of string
|
|
|
|
|
beq .9 no char left, exit with error
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2) get back pattern char
|
|
|
|
|
cmp #'?'
|
|
|
|
|
beq .4 no need to compare, any char will match
|
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.FilterMatch.CmpPtr2CharPtr1Y Regular Char, compare with string at Y
|
2021-06-26 20:24:25 +00:00
|
|
|
|
bne .9 no match, exit
|
|
|
|
|
|
|
|
|
|
.4 iny advance to next char to compare
|
|
|
|
|
bra .1 continue if remaining char in pattern
|
|
|
|
|
|
|
|
|
|
.41 lda (ZPFileName),y end of pattern, but end of string ?
|
|
|
|
|
beq .8 yes, string matched entirely
|
|
|
|
|
* no, remaining char in string, no match
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.5 jsr X.FilterMatch.NextPtr2 we have '*', last char of pattern ?
|
2021-06-26 20:24:25 +00:00
|
|
|
|
beq .8 yes, match everything, including empty string
|
|
|
|
|
|
|
|
|
|
cmp #'*' another '*' ?
|
|
|
|
|
beq .5 yes, '**' = '*', go next char
|
|
|
|
|
|
|
|
|
|
cmp #'?' '*?' ? we must match a least one char
|
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
.7 lda (ZPFileName),y we need at least one remaining char in string, check if at end of string
|
|
|
|
|
beq .9 no chance to match ? or regular char
|
2018-12-17 15:21:32 +00:00
|
|
|
|
|
|
|
|
|
iny
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.FilterMatch.CmpPtr2CharPtr1Y compare with char in string
|
2021-06-26 20:24:25 +00:00
|
|
|
|
bne .7 not equal to next non wildcard in pattern
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
bra .1 go check remaining char in pattern...
|
|
|
|
|
|
|
|
|
|
.8
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.FilterMatch.CLCRTS
|
2020-02-29 14:06:28 +00:00
|
|
|
|
clc
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.FilterMatch.RTS
|
2021-06-26 20:24:25 +00:00
|
|
|
|
rts
|
2018-12-17 15:21:32 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.FilterMatch.CmpPtr2CharPtr1Y
|
|
|
|
|
lda (ZPFileName),y
|
2019-11-29 15:36:54 +00:00
|
|
|
|
phx
|
|
|
|
|
plx
|
2023-02-07 07:04:23 +00:00
|
|
|
|
bne .1 Foreign FS or ProDOS.FX : CS compare
|
2019-11-29 15:36:54 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.ToUpper
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2019-11-29 15:36:54 +00:00
|
|
|
|
.1 cmp (ZPPtr2)
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.FilterMatch.NextPtr2
|
2021-06-26 20:24:25 +00:00
|
|
|
|
inc ZPPtr2 Make PTR2 advance to next char
|
|
|
|
|
bne .1
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2019-10-12 14:20:09 +00:00
|
|
|
|
inc ZPPtr2+1
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2019-10-12 14:20:09 +00:00
|
|
|
|
.1 lda (ZPPtr2)
|
2016-10-20 16:04:35 +00:00
|
|
|
|
rts
|
2019-10-12 14:20:09 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.InitSrcDirYA >STYA ZPPtr1
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.InitSrcDirPtr1
|
|
|
|
|
jsr X.InitGetBuf Get a 256 buffer to store BasePath
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
>STA.G hSrcBasePath
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-09-21 15:29:45 +00:00
|
|
|
|
ldy #1
|
2023-02-07 07:04:23 +00:00
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
beq .8 we have '/'
|
2018-12-20 07:33:10 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
jsr X.Init.Stat
|
2017-09-22 15:25:21 +00:00
|
|
|
|
bcs .1 File/DIR does not exists, go extract pattern
|
2019-04-29 15:47:17 +00:00
|
|
|
|
|
|
|
|
|
.DO X.ENTER.SUBDIR=1
|
2023-11-25 08:33:04 +00:00
|
|
|
|
|
2021-06-27 13:48:04 +00:00
|
|
|
|
>LDA.G STATBUF+S.STAT.MODE+1
|
2021-02-17 16:15:43 +00:00
|
|
|
|
and #$F0
|
|
|
|
|
cmp /S.STAT.MODE.DIR
|
2023-11-25 08:33:04 +00:00
|
|
|
|
bne .7 Not a dir....
|
|
|
|
|
|
|
|
|
|
jsr X.GetPtr2Len
|
|
|
|
|
|
|
|
|
|
dey
|
|
|
|
|
lda #'/'
|
|
|
|
|
cmp (ZPPtr2),y
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
iny
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
|
|
|
|
|
bra .8 TYPE=DIR, do not extract pattern
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
.ELSE
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
bra .7
|
|
|
|
|
|
|
|
|
|
.FIN
|
2021-03-11 21:40:55 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
.1 cmp #MLI.E.INVPATH
|
|
|
|
|
bne .98
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
jsr X.GetPtr2Len TYPE is not DIR, check if wc
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2017-09-21 15:29:45 +00:00
|
|
|
|
dey
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2017-07-05 14:45:19 +00:00
|
|
|
|
ldx #0 Init Wildcard count
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.2 lda (ZPPtr2),y search backward for a /
|
2016-10-19 15:47:53 +00:00
|
|
|
|
cmp #'/'
|
2023-11-25 08:33:04 +00:00
|
|
|
|
beq .6
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2017-07-05 14:45:19 +00:00
|
|
|
|
cmp #'?' Test if some wildcard chars....
|
2023-11-25 08:33:04 +00:00
|
|
|
|
beq .3
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2017-07-05 14:45:19 +00:00
|
|
|
|
cmp #'*'
|
2023-11-25 08:33:04 +00:00
|
|
|
|
bne .4
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
.3 inx inc wildcard count
|
|
|
|
|
|
|
|
|
|
.4 dey
|
2016-10-19 15:47:53 +00:00
|
|
|
|
bne .2
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
.6 txa
|
|
|
|
|
beq .97 no wc, file not found....
|
2017-09-22 15:25:21 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
.7 jsr X.InitSplitBuf
|
2023-02-07 07:04:23 +00:00
|
|
|
|
bcs .99
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
>STA.G hInclude
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.8 >LDYA ZPPtr2
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL OpenDir
|
2023-02-07 07:04:23 +00:00
|
|
|
|
bcs .99
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2016-10-19 15:47:53 +00:00
|
|
|
|
ldy #hDIRs
|
2016-10-28 09:37:57 +00:00
|
|
|
|
sta (pData),y set hDIRs[0] = Src Hdir
|
2016-10-26 20:51:06 +00:00
|
|
|
|
ldy #index
|
|
|
|
|
lda #1
|
2016-10-28 09:37:57 +00:00
|
|
|
|
sta (pData),y index=hDIRs[0]
|
2021-03-11 21:40:55 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
* clc
|
2021-03-11 21:40:55 +00:00
|
|
|
|
|
2016-10-20 16:04:35 +00:00
|
|
|
|
rts
|
2021-07-25 14:03:41 +00:00
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
.97 lda #MLI.E.INVPATH
|
|
|
|
|
.98 sec
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.99 rts
|
2021-06-10 14:00:05 +00:00
|
|
|
|
*--------------------------------------
|
2023-07-12 17:07:55 +00:00
|
|
|
|
.DO X.RESET.SRC.DIR=1
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.ResetSrcDir jsr X.GethDIR
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
|
|
|
|
>SYSCALL CloseDir
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2021-06-10 14:00:05 +00:00
|
|
|
|
>LDA.G hSrcBasePath
|
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>SYSCALL OpenDir
|
|
|
|
|
bcs .9
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2021-06-10 14:00:05 +00:00
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
>LDA.G index
|
|
|
|
|
clc
|
|
|
|
|
adc #hDIRs-1
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
* clc
|
|
|
|
|
.9 rts
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.FIN
|
2017-02-23 16:43:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DO X.COPY.TO.DEST=1
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.InitDstDirYA >STYA ZPPtr1
|
2017-07-05 14:45:19 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.InitDstDirPtr1
|
|
|
|
|
jsr X.InitGetBuf Get a 256 buffer to store BasePath
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
>STA.G hDstBasePath
|
|
|
|
|
|
2023-11-25 08:33:04 +00:00
|
|
|
|
jsr X.Init.Stat
|
2017-06-26 15:28:18 +00:00
|
|
|
|
bcs .1 File/DIR does not exists, go extract DstFileName
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2021-06-27 13:48:04 +00:00
|
|
|
|
>LDA.G STATBUF+S.STAT.MODE+1
|
2021-02-17 16:15:43 +00:00
|
|
|
|
and #$F0
|
|
|
|
|
cmp /S.STAT.MODE.DIR
|
2023-02-07 07:04:23 +00:00
|
|
|
|
beq .8 Dst is a directory...no hDstFileName
|
2017-10-03 15:33:30 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.1 jsr X.InitSplitBuf
|
|
|
|
|
bcs .99
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
>STA.G hDstFileName
|
|
|
|
|
|
|
|
|
|
.8 jmp X.NormalizePtr2
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.99 rts
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.FIN
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
X.InitGetBuf >LDYAI 256
|
|
|
|
|
>SYSCALL GetMem Get a 256 buffer to store BasePath
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
phx
|
|
|
|
|
|
|
|
|
|
>PUSHW ZPPtr1
|
|
|
|
|
>PUSHW ZPPtr2
|
|
|
|
|
>SYSCALL RealPath
|
|
|
|
|
bcs .98
|
|
|
|
|
|
|
|
|
|
pla hBuf
|
|
|
|
|
|
|
|
|
|
* clc
|
2017-10-03 15:33:30 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.98 plx
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
pha
|
2017-06-26 15:28:18 +00:00
|
|
|
|
txa
|
2023-02-07 07:04:23 +00:00
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
pla
|
|
|
|
|
|
|
|
|
|
sec
|
2017-10-03 15:33:30 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2023-11-25 08:33:04 +00:00
|
|
|
|
X.Init.Stat >PUSHW ZPPtr2
|
2023-02-07 07:04:23 +00:00
|
|
|
|
>PUSHEA.G STATBUF
|
|
|
|
|
>SYSCALL Stat
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
X.InitSplitBuf jsr X.GetPtr2Len Search end of string.....
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
lda #'/'
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.1 dey
|
|
|
|
|
cmp (ZPPtr2),y Search backward /
|
|
|
|
|
bne .1
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
tya
|
|
|
|
|
sec +1 to skip '/'
|
|
|
|
|
adc ZPPtr2
|
|
|
|
|
sta ZPPtr1
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
lda ZPPtr2+1
|
|
|
|
|
adc #0
|
|
|
|
|
sta ZPPtr1+1
|
2017-10-03 15:33:30 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
beq .8 path is /dir/
|
|
|
|
|
|
|
|
|
|
>LDYA ZPPtr1
|
|
|
|
|
>SYSCALL StrDup
|
|
|
|
|
bcs .99
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
lda #0
|
2023-02-07 07:04:23 +00:00
|
|
|
|
sta (ZPPtr1)
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
txa
|
2017-06-26 15:28:18 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.8 clc
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.99 rts
|
2016-10-19 15:47:53 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GetNextEntry jsr X.GetEntry
|
2017-02-26 18:34:00 +00:00
|
|
|
|
bcs .9
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetFilenameLen Save actual file len for setting up
|
2018-12-19 16:45:09 +00:00
|
|
|
|
pha new offset later
|
2017-02-26 18:34:00 +00:00
|
|
|
|
lda ZPFileStat
|
2016-10-26 20:51:06 +00:00
|
|
|
|
clc
|
2017-02-26 18:34:00 +00:00
|
|
|
|
adc #S.STAT
|
|
|
|
|
sta ZPFileName
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2017-02-26 18:34:00 +00:00
|
|
|
|
lda ZPFileStat+1
|
|
|
|
|
adc /S.STAT
|
|
|
|
|
sta ZPFileName+1 Make nDIRENTs[i] point to next DIRENT
|
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetFilenameLen are we at end of this buffer ?
|
2017-02-26 18:34:00 +00:00
|
|
|
|
beq .1 yes, go read next one ...
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.SetFileStatPtr
|
2017-02-26 18:34:00 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetoDIRENT
|
2017-02-26 18:34:00 +00:00
|
|
|
|
|
2017-09-21 15:29:45 +00:00
|
|
|
|
pla Get back previous file len
|
2017-02-26 18:34:00 +00:00
|
|
|
|
sec
|
|
|
|
|
adc (pData),y
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
lda #0
|
2017-02-26 18:34:00 +00:00
|
|
|
|
adc (pData),y
|
|
|
|
|
sta (pData),y
|
|
|
|
|
dey
|
|
|
|
|
lda #S.STAT
|
|
|
|
|
clc
|
|
|
|
|
adc (pData),y
|
2016-10-26 20:51:06 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
2017-02-26 18:34:00 +00:00
|
|
|
|
|
|
|
|
|
lda /S.STAT
|
|
|
|
|
adc (pData),y
|
2016-10-26 20:51:06 +00:00
|
|
|
|
sta (pData),y
|
2017-02-26 18:34:00 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2017-09-21 15:29:45 +00:00
|
|
|
|
.1 pla
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetEntry.ReadDir
|
2017-02-26 18:34:00 +00:00
|
|
|
|
bcs .9
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetFilenameLen
|
2021-06-10 14:00:05 +00:00
|
|
|
|
beq .99
|
2018-12-19 16:45:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.SetFileStatPtr
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2017-02-26 18:34:00 +00:00
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
2021-06-10 14:00:05 +00:00
|
|
|
|
.99 sec
|
2017-02-26 18:34:00 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GetEntry jsr X.GethDIRENT
|
2017-02-26 18:34:00 +00:00
|
|
|
|
bne .1 we have a buffer to scan
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetEntry.ReadDir First run, get first block
|
2017-02-26 18:34:00 +00:00
|
|
|
|
bcs .9 ZPFileName = start of buffer
|
2016-10-26 20:51:06 +00:00
|
|
|
|
|
2017-02-26 18:34:00 +00:00
|
|
|
|
lda (ZPFileName) Empty !!!
|
|
|
|
|
bne .8
|
2018-12-19 16:45:09 +00:00
|
|
|
|
|
2017-02-26 18:34:00 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2018-07-18 15:30:42 +00:00
|
|
|
|
.1 >SYSCALL GetMemPtr
|
2021-06-26 20:24:25 +00:00
|
|
|
|
>STYA ZPFileName
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetoDIRENT
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2017-02-24 16:34:02 +00:00
|
|
|
|
lda ZPFileName
|
|
|
|
|
clc
|
2016-10-26 20:51:06 +00:00
|
|
|
|
adc (pData),y
|
2017-02-24 16:34:02 +00:00
|
|
|
|
sta ZPFileName
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
iny
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2017-02-24 16:34:02 +00:00
|
|
|
|
lda ZPFileName+1
|
2016-10-26 20:51:06 +00:00
|
|
|
|
adc (pData),y
|
2017-02-26 18:34:00 +00:00
|
|
|
|
sta ZPFileName+1 ZPFileName=ZPFileName+oDIRENT
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.8 jsr X.GetFilenameLen
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.SetFileStatPtr
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2017-02-26 18:34:00 +00:00
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GetEntry.ReadDir
|
|
|
|
|
jsr X.GethDIRENT
|
2017-02-26 18:34:00 +00:00
|
|
|
|
beq .1
|
2018-11-21 13:08:11 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
pha
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y reset hDIRENT
|
|
|
|
|
pla
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem discard previous hDIRENT
|
2016-10-26 20:51:06 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.1 jsr X.GethDIR
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL ReadDir
|
2017-02-26 18:34:00 +00:00
|
|
|
|
bcs .9
|
2020-03-17 16:03:32 +00:00
|
|
|
|
|
2017-02-26 18:34:00 +00:00
|
|
|
|
>STYA ZPFileName
|
|
|
|
|
ldy #index
|
|
|
|
|
lda (pData),y
|
|
|
|
|
clc
|
|
|
|
|
adc #hDIRENTs-1
|
|
|
|
|
tay
|
|
|
|
|
txa get hDIRENT in A
|
2016-10-26 20:51:06 +00:00
|
|
|
|
sta (pData),y
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetoDIRENT
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2018-11-21 13:08:11 +00:00
|
|
|
|
lda #0 and reset offset for this buffer
|
2017-02-26 18:34:00 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
2016-10-26 20:51:06 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
clc
|
2017-02-26 18:34:00 +00:00
|
|
|
|
.9 rts
|
2016-10-25 06:58:15 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.EnterSubDirYA >STYA ZPPtr1 save SUBDIR for StrCat
|
2016-10-20 16:04:35 +00:00
|
|
|
|
|
2019-04-29 15:47:17 +00:00
|
|
|
|
>LDA.G index
|
2016-11-08 16:56:05 +00:00
|
|
|
|
cmp #X.MAX.RECURSE
|
2016-10-26 20:51:06 +00:00
|
|
|
|
beq .9
|
2016-10-20 16:04:35 +00:00
|
|
|
|
|
2016-11-08 16:56:05 +00:00
|
|
|
|
ldy #hSrcBasePath
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.EnterSubDirY
|
|
|
|
|
>LDYA ZPPtr2
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL OpenDir
|
2016-10-26 20:51:06 +00:00
|
|
|
|
bcs .9
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2016-10-20 16:04:35 +00:00
|
|
|
|
pha
|
2018-11-21 13:08:11 +00:00
|
|
|
|
>INC.G index
|
2016-10-26 20:51:06 +00:00
|
|
|
|
tax
|
|
|
|
|
* clc from BCS
|
|
|
|
|
adc #hDIRs-1
|
2016-10-20 16:04:35 +00:00
|
|
|
|
tay
|
|
|
|
|
pla
|
|
|
|
|
sta (pData),y
|
2016-10-26 20:51:06 +00:00
|
|
|
|
txa make sure hDIRENTs[i] is closed
|
|
|
|
|
adc #hDIRENTs-1
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2017-02-21 17:01:30 +00:00
|
|
|
|
.DO X.COPY.TO.DEST=1
|
2016-11-13 21:03:31 +00:00
|
|
|
|
ldy #hDstBasePath
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.EnterSubDirY
|
2016-11-13 21:03:31 +00:00
|
|
|
|
.FIN
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2017-02-26 18:34:00 +00:00
|
|
|
|
clc
|
2016-10-26 20:51:06 +00:00
|
|
|
|
.9 rts
|
2023-02-07 07:04:23 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
X.EnterSubDirY lda (pData),y
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
2023-02-07 07:04:23 +00:00
|
|
|
|
>STYA ZPPtr2 save full path
|
2018-11-21 13:08:11 +00:00
|
|
|
|
|
2016-11-13 21:03:31 +00:00
|
|
|
|
>PUSHW ZPPtr2
|
2023-02-07 07:04:23 +00:00
|
|
|
|
>PUSHW ZPPtr1
|
2017-09-21 15:29:45 +00:00
|
|
|
|
>SYSCALL StrCat
|
2016-11-13 21:03:31 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.NormalizePtr2 jsr X.GetPtr2Len
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2018-11-21 13:08:11 +00:00
|
|
|
|
dey
|
2016-11-13 21:03:31 +00:00
|
|
|
|
lda #'/'
|
2023-02-07 07:04:23 +00:00
|
|
|
|
cmp (ZPPtr2),y
|
2018-11-21 13:08:11 +00:00
|
|
|
|
beq .8
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2018-11-21 13:08:11 +00:00
|
|
|
|
iny
|
2023-02-07 07:04:23 +00:00
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
|
2017-09-22 15:25:21 +00:00
|
|
|
|
iny
|
|
|
|
|
lda #0
|
2023-02-07 07:04:23 +00:00
|
|
|
|
sta (ZPPtr2),y
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
2016-10-19 15:47:53 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.LeaveSubDir >LDA.G index
|
2021-07-25 14:03:41 +00:00
|
|
|
|
beq .7
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GethDIRENT.A
|
|
|
|
|
jsr X.LeaveSubDir.free
|
2018-12-20 07:33:10 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GethDIR
|
2021-07-25 14:03:41 +00:00
|
|
|
|
beq .1
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
pha
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
pla
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL CloseDir
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
2021-07-25 14:03:41 +00:00
|
|
|
|
.1 >DEC.G index
|
2016-11-01 21:37:12 +00:00
|
|
|
|
bne .8
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2021-07-25 14:03:41 +00:00
|
|
|
|
.7 >LDA.G hSrcBasePath
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.LeaveSubDir.free
|
2018-12-20 07:33:10 +00:00
|
|
|
|
|
2017-02-27 14:18:03 +00:00
|
|
|
|
.DO X.COPY.TO.DEST=1
|
2021-07-25 14:03:41 +00:00
|
|
|
|
>LDA.G hDstBasePath
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.LeaveSubDir.free
|
2017-02-27 14:18:03 +00:00
|
|
|
|
.FIN
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2021-07-25 14:03:41 +00:00
|
|
|
|
sec
|
2016-10-30 18:19:43 +00:00
|
|
|
|
rts
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2016-11-01 21:37:12 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
2021-07-25 14:03:41 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.LeaveSubDir.free
|
2021-07-25 14:03:41 +00:00
|
|
|
|
tax
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
txa
|
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
|
|
|
|
|
.8 rts
|
2016-10-30 18:19:43 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.BasePath.. .DO X.COPY.TO.DEST=1
|
2017-10-04 15:12:03 +00:00
|
|
|
|
|
2016-11-13 21:03:31 +00:00
|
|
|
|
ldy #hDstBasePath
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.BasePath..1
|
2016-11-13 21:03:31 +00:00
|
|
|
|
.FIN
|
|
|
|
|
ldy #hSrcBasePath
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.BasePath..1 lda (pData),y
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
2023-02-07 07:04:23 +00:00
|
|
|
|
>STYA ZPPtr2 save full path
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
jsr X.GetPtr2Len get len
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2017-10-04 15:12:03 +00:00
|
|
|
|
dey discard ending /
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2017-09-22 15:25:21 +00:00
|
|
|
|
.2 dey
|
2023-02-07 07:04:23 +00:00
|
|
|
|
lda (ZPPtr2),y
|
2016-10-20 16:04:35 +00:00
|
|
|
|
cmp #'/'
|
2017-09-22 15:25:21 +00:00
|
|
|
|
bne .2
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2017-09-22 15:25:21 +00:00
|
|
|
|
iny
|
|
|
|
|
lda #0
|
2023-02-07 07:04:23 +00:00
|
|
|
|
sta (ZPPtr2),y cut DIR2/ from /dir1/DIR2/
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
rts
|
2016-10-18 06:26:24 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.ToUpper cmp #'a'
|
|
|
|
|
bcc .8
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
cmp #'z'+1
|
|
|
|
|
bcs .8
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
eor #$20
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
.8 rts
|
2019-10-12 14:20:09 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GetPtr2Len ldy #$ff
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
|
|
|
|
.1 iny
|
2023-02-07 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
lda (ZPPtr2),y get len
|
2019-10-12 14:20:09 +00:00
|
|
|
|
bne .1
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
rts
|
2019-10-12 14:20:09 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GetFilenameLen
|
|
|
|
|
ldy #$ff
|
2018-12-19 16:45:09 +00:00
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPFileName),y
|
|
|
|
|
bne .1
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2018-12-19 16:45:09 +00:00
|
|
|
|
tya
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.SetFileStatPtr
|
|
|
|
|
sec
|
2018-12-19 16:45:09 +00:00
|
|
|
|
adc ZPFileName
|
|
|
|
|
sta ZPFileStat
|
|
|
|
|
lda ZPFileName+1
|
|
|
|
|
adc #0
|
|
|
|
|
sta ZPFileStat+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GethDIR >LDA.G index
|
2021-06-26 20:24:25 +00:00
|
|
|
|
|
2018-11-21 13:08:11 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #hDIRs-1
|
|
|
|
|
tay
|
|
|
|
|
lda (pData),y
|
|
|
|
|
rts
|
2019-10-03 06:25:27 +00:00
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GethDIRENT >LDA.G index
|
2021-06-10 14:00:05 +00:00
|
|
|
|
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GethDIRENT.A clc
|
2018-11-21 13:08:11 +00:00
|
|
|
|
adc #hDIRENTs-1
|
|
|
|
|
tay
|
|
|
|
|
lda (pData),y
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2023-02-07 07:04:23 +00:00
|
|
|
|
X.GetoDIRENT >LDA.G index
|
2018-11-21 13:08:11 +00:00
|
|
|
|
asl
|
|
|
|
|
clc
|
|
|
|
|
adc #oDIRENTs-1
|
|
|
|
|
tay
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-10-18 06:26:24 +00:00
|
|
|
|
MAN
|
2020-08-25 14:54:30 +00:00
|
|
|
|
SAVE usr/src/shared/x.fileenum.s
|
2023-07-12 17:07:55 +00:00
|
|
|
|
LOAD usr/src/bin/ls.s
|
2018-07-20 11:51:08 +00:00
|
|
|
|
ASM
|