CIFSD:bugfix & type/auxtype mapping

CP,MV,RM:memory leak & new X.FILEENUM
LIBTUI:TBOX improvment
This commit is contained in:
burniouf 2023-02-07 08:04:23 +01:00
parent c4ca3e5907
commit 17aee1f2a8
15 changed files with 1016 additions and 878 deletions

Binary file not shown.

Binary file not shown.

View File

@ -19,17 +19,19 @@ X.DELETE.SOURCE .EQ 0
*-------------------------------------- *--------------------------------------
CS.END CS.END
*-------------------------------------- *--------------------------------------
OptionList .AS "CcQqRrYy" OptionList .AS "IiCcQqRrYy"
OptionVars .DA #bContinue,#bContinue OptionVars .DA #0,#0
.DA #bContinue,#bContinue
.DA #bQuiet,#bQuiet .DA #bQuiet,#bQuiet
.DA #bRecurse,#bRecurse .DA #bRecurse,#bRecurse
.DA #bNoConfirm,#bNoConfirm .DA #bNoConfirm,#bNoConfirm
*-------------------------------------- *--------------------------------------
MSG.USAGE .CS "Usage : CP [Src File/Dir, *,? wildcards allowed]\r\n" MSG.USAGE .CS "Usage : CP [Src File/Dir, *,? wildcards allowed]\r\n"
.CS " -C : Continue on error\r\n" .CS " -C : Continue on error\r\n"
.CS " -I <*,? wildcards allowed> : Ignore matching files\r\n"
.CS " -Q : Quiet\r\n" .CS " -Q : Quiet\r\n"
.CS " -R : Recurse subdirectories\r\n" .CS " -R : Recurse subdirectories\r\n"
.CZ " -Y : Don't prompt for override\r\n" .CZ " -Y : Don't prompt for overwrite\r\n"
MSG.DIR .CZ "CP Dir :%s to %s..." MSG.DIR .CZ "CP Dir :%s to %s..."
MSG.REG .CZ "CP File:%s to %s..." MSG.REG .CZ "CP File:%s to %s..."
MSG.OVERWRITE .CZ "Overwrite %s [Yes,No,All]?" MSG.OVERWRITE .CZ "Overwrite %s [Yes,No,All]?"
@ -40,7 +42,7 @@ MSG.DONE .CZ "%D File(s) Copied.\r\n"
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR 0 .OR 0
DS.START .INB usr/src/shared/x.cpmvrm.g DS.START
.INB usr/src/shared/x.fileenum.g .INB usr/src/shared/x.fileenum.g
DS.END .ED DS.END .ED
*-------------------------------------- *--------------------------------------

View File

@ -894,6 +894,7 @@ MSG.USAGE .CS "Usage : LS [-A] [-C] [-F] [-L] [-R] [filespec]\r\n"
.CS " -A : Show all files\r\n" .CS " -A : Show all files\r\n"
.CS " -C : List in one column\r\n" .CS " -C : List in one column\r\n"
.CS " -F : Show full paths\r\n" .CS " -F : Show full paths\r\n"
.CS " -I <*,? wildcards allowed> : Ignore matching files\r\n"
.CS " -L : Use long listing format\r\n" .CS " -L : Use long listing format\r\n"
.CZ " -R : Recursively list subdirectories\r\n" .CZ " -R : Recursively list subdirectories\r\n"
*-------------------------------------- *--------------------------------------

View File

@ -19,17 +19,19 @@ X.DELETE.SOURCE .EQ 1
*-------------------------------------- *--------------------------------------
CS.END CS.END
*-------------------------------------- *--------------------------------------
OptionList .AS "CcQqRrYy" OptionList .AS "IiCcQqRrYy"
OptionVars .DA #bContinue,#bContinue OptionVars .DA #0,#0
.DA #bContinue,#bContinue
.DA #bQuiet,#bQuiet .DA #bQuiet,#bQuiet
.DA #bRecurse,#bRecurse .DA #bRecurse,#bRecurse
.DA #bNoConfirm,#bNoConfirm .DA #bNoConfirm,#bNoConfirm
*-------------------------------------- *--------------------------------------
MSG.USAGE .CS "Usage : MV [Src File/Dir, *,? wildcards allowed]\r\n" MSG.USAGE .CS "Usage : MV [Src File/Dir, *,? wildcards allowed]\r\n"
.CS " -C : Continue on error\r\n" .CS " -C : Continue on error\r\n"
.CS " -I <*,? wildcards allowed> : Ignore matching files\r\n"
.CS " -Q : Quiet\r\n" .CS " -Q : Quiet\r\n"
.CS " -R : Recurse subdirectories\r\n" .CS " -R : Recurse subdirectories\r\n"
.CZ " -Y : Dont't prompt for override\r\n" .CZ " -Y : Dont't prompt for overwrite\r\n"
MSG.DIR .CZ "MV Dir :%s to %s..." MSG.DIR .CZ "MV Dir :%s to %s..."
MSG.REG .CZ "MV File:%s to %s..." MSG.REG .CZ "MV File:%s to %s..."
MSG.OVERWRITE .CZ "Overwrite %s [Yes,No,All]?" MSG.OVERWRITE .CZ "Overwrite %s [Yes,No,All]?"
@ -40,7 +42,7 @@ MSG.DONE .CZ "%D File(s) Moved.\r\n"
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR 0 .OR 0
DS.START .INB usr/src/shared/x.cpmvrm.g DS.START
.INB usr/src/shared/x.fileenum.g .INB usr/src/shared/x.fileenum.g
DS.END .ED DS.END .ED
*-------------------------------------- *--------------------------------------

View File

@ -19,13 +19,15 @@ X.DELETE.SOURCE .EQ 1
*-------------------------------------- *--------------------------------------
CS.END CS.END
*-------------------------------------- *--------------------------------------
OptionList .AS "CcQqRr" OptionList .AS "IiCcQqRr"
OptionVars .DA #bContinue,#bContinue OptionVars .DA #0,#0
.DA #bContinue,#bContinue
.DA #bQuiet,#bQuiet .DA #bQuiet,#bQuiet
.DA #bRecurse,#bRecurse .DA #bRecurse,#bRecurse
*-------------------------------------- *--------------------------------------
MSG.USAGE .CS "Usage : RM [File/Dir, *,? wildcards allowed]\r\n" MSG.USAGE .CS "Usage : RM [File/Dir, *,? wildcards allowed]\r\n"
.CS " -C : Continue on error\r\n" .CS " -C : Continue on error\r\n"
.CS " -I <*,? wildcards allowed> : Ignore matching files\r\n"
.CS " -Q : Quiet\r\n" .CS " -Q : Quiet\r\n"
.CZ " -R : Recurse subdirectories\r\n" .CZ " -R : Recurse subdirectories\r\n"
MSG.DIR .CZ "RM Dir :%s..." MSG.DIR .CZ "RM Dir :%s..."
@ -37,7 +39,7 @@ MSG.DONE .CZ "%D File(s) Removed.\r\n"
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR 0 .OR 0
DS.START .INB usr/src/shared/x.cpmvrm.g DS.START
.INB usr/src/shared/x.fileenum.g .INB usr/src/shared/x.fileenum.g
DS.END .ED DS.END .ED
*-------------------------------------- *--------------------------------------

View File

@ -922,6 +922,12 @@ OBJ.CurOff ldy #S.OBJ.F
clc clc
rts rts
*-------------------------------------- *--------------------------------------
OBJ.ZeroWordAtY lda #0
lda (ZPObjPtr),y
iny
sta (ZPObjPtr),y
rts
*--------------------------------------
OBJ.IncWordAtY lda (ZPObjPtr),y OBJ.IncWordAtY lda (ZPObjPtr),y
inc inc
sta (ZPObjPtr),y sta (ZPObjPtr),y

View File

@ -161,7 +161,7 @@ TBOX.RUN.BS ldy #S.TBOX.BufPtr+1
*-------------------------------------- *--------------------------------------
TBOX.RUN.LF jsr TBOX.GetBuf TBOX.RUN.LF jsr TBOX.GetBuf
jsr TBOX.GetCurlineInAX TBOX.RUN.LF1 jsr TBOX.GetCurlineInAX
inx inx
bne .1 bne .1
@ -304,7 +304,22 @@ TBOX.RUN.CR jsr TBOX.GetBuf
jsr TBOX.ToBuf1 jsr TBOX.ToBuf1
bcs .8 Buffer full bcs .8 Buffer full
jmp TBOX.RUN.FS1 lda #0
ldy #S.TBOX.DocX
sta (ZPObjPtr),y
iny
sta (ZPObjPtr),y
jsr TBOX.RUN.LF1
jsr OBJ.CurUpdPos
bit bRepaintAll
bmi .1
jsr TBOX.DrawBottom
.1 jmp TBOX.DrawAllLines
.8 clc .8 clc
rts rts
@ -316,7 +331,7 @@ TBOX.RUN.PGDN lda #0
rts rts
*-------------------------------------- *--------------------------------------
TBOX.RUN.QUIT lda #3 User Interrupt TBOX.RUN.QUIT lda #3 User Interrupt
clc sec
rts rts
*-------------------------------------- *--------------------------------------
TBOX.RUN.Home ldy #S.TBOX.DocX TBOX.RUN.Home ldy #S.TBOX.DocX
@ -391,6 +406,30 @@ TBOX.DrawAllLines
rts rts
*-------------------------------------- *--------------------------------------
TBOX.DrawBottom ldy #S.OBJ.InnerY
lda (ZPObjPtr),y
clc
ldy #S.OBJ.CurY
adc (ZPObjPtr),y
>PUSHA Start
ldy #S.OBJ.InnerH
lda (ZPObjPtr),y
sec
ldy #S.OBJ.CurY
sbc (ZPObjPtr),y
>PUSHA Count
ldy #S.OBJ.CurY
lda (ZPObjPtr),y Relative Y
>PUSHA
jmp OBJ.Draw.Lines
*--------------------------------------
TBOX.DrawCurLine TBOX.DrawCurLine
ldy #S.OBJ.InnerY ldy #S.OBJ.InnerY
lda (ZPObjPtr),y lda (ZPObjPtr),y
@ -425,15 +464,15 @@ TBOX.Draw ldy #S.TBOX.VScroll
ldy #S.TBOX.HScroll ldy #S.TBOX.HScroll
lda (ZPObjPtr),y lda (ZPObjPtr),y
beq .12
tax tax
beq .12
.1 jsr TBOX.GetLineChar .1 jsr TBOX.GetLineChar
beq .12 beq .5
cmp #C.CR cmp #C.CR
beq .12 beq .5
dex dex
bne .1 bne .1

View File

@ -112,6 +112,14 @@ CORE.AppendPathPtr2
rts rts
*-------------------------------------- *--------------------------------------
CORE.AppendTypePtr2 CORE.AppendTypePtr2
pha
lda #'.'
sta (ZPPtr2),y
iny
pla
ldx #0 ldx #0
.1 cmp PRODOS.FT.HEX,x .1 cmp PRODOS.FT.HEX,x
@ -121,6 +129,43 @@ CORE.AppendTypePtr2
cpx #PRODOS.FT.TXT-PRODOS.FT.HEX cpx #PRODOS.FT.TXT-PRODOS.FT.HEX
bne .1 bne .1
pha
lda #'0'
sta (ZPPtr2),y
iny
pla
bra CORE.AppendHEXPtr2
.4 txa
asl
asl
tax
.6 lda PRODOS.FT.TXT,x
sta (ZPPtr2),y
beq .8
inx
iny
bra .6
.8 rts
*--------------------------------------
CORE.AppendAuxTPtr2
pha
lda #'_'
sta (ZPPtr2),y
iny
pla
jsr CORE.AppendHEXPtr2
txa
*--------------------------------------
CORE.AppendHEXPtr2
pha pha
lsr lsr
lsr lsr
@ -133,7 +178,9 @@ CORE.AppendTypePtr2
adc #6 adc #6
.2 sta PRODOS.FT.DFLT+1 .2 sta (ZPPtr2),y
iny
pla pla
and #$0F and #$0F
@ -143,26 +190,10 @@ CORE.AppendTypePtr2
adc #6 adc #6
.3 sta PRODOS.FT.DFLT+2 .3 sta (ZPPtr2),y
.4 txa
asl
asl
tax
lda #'.'
sta (ZPPtr2),y
iny iny
.6 lda PRODOS.FT.TXT,x rts
sta (ZPPtr2),y
beq .8
inx
iny
bra .6
.8 rts
*-------------------------------------- *--------------------------------------
CORE.Add2ByteCount CORE.Add2ByteCount
ldy ByteCountOfs ldy ByteCountOfs
@ -256,7 +287,6 @@ CORE.SetReqLen lda ZPReqLen
sta (ZPReqPtr),y sta (ZPReqPtr),y
lda ZPReqLen+1 lda ZPReqLen+1
sec
sbc /S.NETBIOS sbc /S.NETBIOS
dey dey
sta (ZPReqPtr),y sta (ZPReqPtr),y

View File

@ -472,72 +472,12 @@ IO.R.ReadDir.FillBuf
sec sec
jsr IO.AddA2Ptr1 jsr IO.AddA2Ptr1
txa jsr IO.R.ReadDir.AuxT
sec
sbc #4 "x.EXT" ?
bcc .7
tay jsr IO.R.ReadDir.Type
lda (ZPPtr2),y
cmp #'.'
bne .7
ldx #0
.4 phy Y = '.' offset
phx
.5 iny
lda (ZPPtr2),y
beq .51
cmp #'A'
bcc .50
cmp #'Z'+1
bcs .50
eor #$20
.50 cmp PRODOS.FT.TXT,x
bne .6
inx
bra .5
.51 pla
lsr
lsr
tax
lda PRODOS.FT.HEX,x
sta StatBuf+S.STAT.P.TYPE
ply
lda #0
sta (ZPPtr2),y
tya
bra .70
.6 pla
clc
adc #4
tax
ply
cpx #PRODOS.FT.END
bne .4
tya
* sec
adc #3
bra .70
.7 txa .7 txa
.70 sec +\0 sec +\0
jsr IO.AddA2Ptr2 jsr IO.AddA2Ptr2
jsr IO.StatBuf2Ptr2 jsr IO.StatBuf2Ptr2
@ -552,6 +492,180 @@ IO.R.ReadDir.FillBuf
sta (ZPPtr2) sta (ZPPtr2)
rts rts
*--------------------------------------
IO.R.ReadDir.AuxT
txa X = filename len
sec
sbc #5 "x.EXT_hhhh" ?
bcc .99
beq .99
tay
lda (ZPPtr2),y
cmp #'_'
bne .99
phy
iny
lda (ZPPtr2),y
jsr IO.IsHexDigit
bcs .9
asl
asl
asl
asl
sta StatBuf+S.STAT.P.AUXTYPE+1
iny
lda (ZPPtr2),y
jsr IO.IsHexDigit
bcs .9
ora StatBuf+S.STAT.P.AUXTYPE+1
sta StatBuf+S.STAT.P.AUXTYPE+1
iny
lda (ZPPtr2),y
jsr IO.IsHexDigit
bcs .9
asl
asl
asl
asl
sta StatBuf+S.STAT.P.AUXTYPE
iny
lda (ZPPtr2),y
jsr IO.IsHexDigit
bcs .9
ora StatBuf+S.STAT.P.AUXTYPE
sta StatBuf+S.STAT.P.AUXTYPE
pla
tax
tay
lda #0
sta (ZPPtr2),y
rts
.9 plx
.99 stz StatBuf+S.STAT.P.AUXTYPE
stz StatBuf+S.STAT.P.AUXTYPE+1
rts
*--------------------------------------
IO.R.ReadDir.Type
txa X = filename len
sec
sbc #4 "x.EXT" ?
bcc .99
beq .99
tay
lda (ZPPtr2),y
cmp #'.'
bne .99
phx
ldx #0
.1 phy Y = '.' offset
.2 iny
lda (ZPPtr2),y
beq .4
cmp #'A'
bcc .3
cmp #'Z'+1
bcs .3
eor #$20
.3 cmp PRODOS.FT.TXT,x
bne .5
inx
bra .2
.4 txa
lsr
lsr
tax
lda PRODOS.FT.HEX,x
sta StatBuf+S.STAT.P.TYPE
ply
bra .8
.5 txa
and #$FC
clc
adc #4
tax
ply
cpx #PRODOS.FT.END
bne .1
iny
lda (ZPPtr2),y
cmp #'0'
bne .9
iny
lda (ZPPtr2),y
jsr IO.IsHexDigit
bcs .9
asl
asl
asl
asl
sta StatBuf+S.STAT.P.TYPE
iny
lda (ZPPtr2),y
jsr IO.IsHexDigit
bcs .9
ora StatBuf+S.STAT.P.TYPE
sta StatBuf+S.STAT.P.TYPE
.8 pla
sec
sbc #4
tax
tay
lda #0
sta (ZPPtr2),y
rts
.9 plx
.99 stz StatBuf+S.STAT.P.TYPE
rts
*--------------------------------------
*-------------------------------------- *--------------------------------------
IO.Q.CloseReg IO.Q.CloseReg
IO.Q.CloseDir tax IO.Q.CloseDir tax
@ -594,18 +708,38 @@ IO.Q.FOpen >STYA pPath resolved path
jsr CORE.ReqSetupPtr2 jsr CORE.ReqSetupPtr2
ldy #2
lda (pStack),y TYPE
pha
jsr CORE.AppendPathPtr2 jsr CORE.AppendPathPtr2
pla phy
ldy #2
lda (pStack),y TYPE
beq .2 beq .2
ply
jsr CORE.AppendTypePtr2 jsr CORE.AppendTypePtr2
.2 jsr CORE.AddYReqLen phy
lda (pStack) AUXT
tax
ldy #1
ora (pStack),y
beq .2
lda (pStack),y AUXT
ply
jsr CORE.AppendAuxTPtr2
phy
.2 ply
jsr CORE.AddYReqLen
tya tya
@ -784,8 +918,6 @@ IO.R.FClose sta hFILE
.99 jmp IO.SleepCont .99 jmp IO.SleepCont
*-------------------------------------- *--------------------------------------
*
*--------------------------------------
IO.Q.FRead ldy #4 hFILE IO.Q.FRead ldy #4 hFILE
lda (pStack),y lda (pStack),y
@ -1541,6 +1673,45 @@ IO.FileInfo2StatBufDT
rts rts
*-------------------------------------- *--------------------------------------
IO.IsHexDigit jsr IO.IsDigit
bcc .8
cmp #'A'
bcc .9
cmp #'F'+1
bcc .1
cmp #'a'
bcc .9
cmp #'f'+1
bcs .99
eor #$20
.1
* clc
sbc #'A'-11 cc so A->10 (11-CC)
clc
.8 rts
.9 sec
.99 rts
*--------------------------------------
IO.IsDigit cmp #'0'
bcc .9
cmp #'9'+1
bcs .99
and #$0F
* clc
rts
.9 sec
.99 rts
*--------------------------------------
MAN MAN
SAVE usr/src/sbin/cifsd.s.io SAVE usr/src/sbin/cifsd.s.io
LOAD usr/src/sbin/cifsd.s LOAD usr/src/sbin/cifsd.s

View File

@ -450,7 +450,6 @@ PRODOS.FT.TXT .AZ "txt"
.AZ "pak" .AZ "pak"
.AZ "sys" .AZ "sys"
PRODOS.FT.END .EQ *-PRODOS.FT.TXT PRODOS.FT.END .EQ *-PRODOS.FT.TXT
PRODOS.FT.DFLT .AZ "$ "
*-------------------------------------- *--------------------------------------
SMBERR01 .DA #2,#3,#32 SMBERR01 .DA #2,#3,#32
MLIERR01 .DA #MLI.E.FNOTFND,#MLI.E.PNOTFND,#MLI.E.OPEN MLIERR01 .DA #MLI.E.FNOTFND,#MLI.E.PNOTFND,#MLI.E.OPEN

View File

@ -1,31 +0,0 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
ArgCount .BS 1
bPause .BS 1
hSrcFullPath .BS 1
Count .BS 2
RC .BS 1
.DO X.COPY.TO.DEST=1
hDstFileName .BS 1
hDstFullPath .BS 1
bCopy .BS 1
hSrcFile .BS 1
hDstFile .BS 1
hCopyBuf .BS 1
CopyRC .BS 1
.FIN
.DO X.DELETE.SOURCE=1
hToDelete .BS 1
.FIN
*--------------------------------------
MAN
SAVE usr/src/shared/x.cpmvrm.g
LOAD usr/src/bin/cp.s
ASM

File diff suppressed because it is too large Load Diff

View File

@ -6,15 +6,17 @@ hDIRs .BS X.MAX.RECURSE+1
hDIRENTs .BS X.MAX.RECURSE+1 hDIRENTs .BS X.MAX.RECURSE+1
oDIRENTs .BS X.MAX.RECURSE*2 oDIRENTs .BS X.MAX.RECURSE*2
STATBUF .BS S.STAT STATBUF .BS S.STAT
hFullPath .BS 1
hSrcBasePath .BS 1 hInclude .BS 1
hFilter .BS 1
hExclude .BS 1 hExclude .BS 1
hSrcBasePath .BS 1
.DO X.COPY.TO.DEST=1 .DO X.COPY.TO.DEST=1
hDstBasePath .BS 1 hDstBasePath .BS 1
hDstFileName .BS 1
.FIN .FIN
*-------------------------------------- *--------------------------------------
MAN MAN
SAVE usr/src/shared/x.fileenum.g SAVE usr/src/shared/x.fileenum.g
LOAD usr/src/bin/ls.s LOAD usr/src/bin/cp.s
ASM ASM

View File

@ -4,7 +4,13 @@ NEW
*-------------------------------------- *--------------------------------------
X.MAX.RECURSE .EQ 8 X.MAX.RECURSE .EQ 8
*-------------------------------------- *--------------------------------------
* Uses: (pData) * Uses:
* (ZP)
* ZPPtr1 .BS 2
* ZPPtr2 .BS 2
* ZPFileName .BS 2
* ZPFileStat .BS 2
* (pData)
* Index .BS 1 * Index .BS 1
* hDIRs .BS X.MAX.RECURSE+1 * hDIRs .BS X.MAX.RECURSE+1
* hDIRENTs .BS X.MAX.RECURSE+1 * hDIRENTs .BS X.MAX.RECURSE+1
@ -12,38 +18,35 @@ X.MAX.RECURSE .EQ 8
* STATBUF .BS S.STAT * STATBUF .BS S.STAT
* hSrcBasePath .BS 1 * hSrcBasePath .BS 1
* hDstBasePath .BS 1 (optional) * hDstBasePath .BS 1 (optional)
* hFilter .BS 1 * hInclude .BS 1
* hExclude .BS 1 * hExclude .BS 1
*-------------------------------------- *--------------------------------------
* Compare a ZPFileName against hFilter (e.g. '*test?.*') * Compare a ZPFileName against hInclude (e.g. '*test?.*')
* CC : match * CC : match
* CS : no match * CS : no match
*-------------------------------------- *--------------------------------------
FilterMatch >LDA.G index X.IncludeMatch >LDA.G index
dec dec
bne FilterMatch.CLCRTS in a subdir, match everything bne X.FilterMatch.CLCRTS in a subdir, match everything
clc clc
.HS B0 BCS .HS B0 BCS
ExcludeMatch sec X.IgnoreMatch sec
php ldy #hInclude
lda #hFilter bcc .11
adc #0
tay
lda (pData),y
plp
tax iny
beq FilterMatch.RTS No filter....exit with passed carry .11 lda (pData),y
beq X.FilterMatch.RTS No filter....exit with passed carry
>SYSCALL GetMemPtr >SYSCALL GetMemPtr
>STYA ZPPtr2 >STYA ZPPtr2
ldy #S.STAT.FSID ldy #S.STAT.FSID
lda (ZPFileStat),y if 0, Regular ProDOS.... lda (ZPFileStat),y if 0, Regular ProDOS....
pha save FSID for comapring later pha save FSID for comparing later
bne .10 bne .10
>LDYA ZPPtr2 ... so CI compare >LDYA ZPPtr2 ... so CI compare
@ -57,7 +60,7 @@ ExcludeMatch sec
ldy #0 ldy #0
bra .2 bra .2
.1 jsr FilterMatch.NextPtr2 get next pattern char .1 jsr X.FilterMatch.NextPtr2 get next pattern char
beq .41 end of pattern... beq .41 end of pattern...
.2 cmp #'*' .2 cmp #'*'
@ -70,7 +73,7 @@ ExcludeMatch sec
cmp #'?' cmp #'?'
beq .4 no need to compare, any char will match beq .4 no need to compare, any char will match
jsr FilterMatch.CmpPtr2CharPtr1Y Regular Char, compare with string at Y jsr X.FilterMatch.CmpPtr2CharPtr1Y Regular Char, compare with string at Y
bne .9 no match, exit bne .9 no match, exit
.4 iny advance to next char to compare .4 iny advance to next char to compare
@ -82,7 +85,7 @@ ExcludeMatch sec
.9 sec .9 sec
rts rts
.5 jsr FilterMatch.NextPtr2 we have '*', last char of pattern ? .5 jsr X.FilterMatch.NextPtr2 we have '*', last char of pattern ?
beq .8 yes, match everything, including empty string beq .8 yes, match everything, including empty string
cmp #'*' another '*' ? cmp #'*' another '*' ?
@ -95,40 +98,30 @@ ExcludeMatch sec
beq .9 no chance to match ? or regular char beq .9 no chance to match ? or regular char
iny iny
jsr FilterMatch.CmpPtr2CharPtr1Y compare with char in string jsr X.FilterMatch.CmpPtr2CharPtr1Y compare with char in string
bne .7 not equal to next non wildcard in pattern bne .7 not equal to next non wildcard in pattern
iny iny
bra .1 go check remaining char in pattern... bra .1 go check remaining char in pattern...
.8 .8
FilterMatch.CLCRTS X.FilterMatch.CLCRTS
clc clc
FilterMatch.RTS X.FilterMatch.RTS
rts rts
*-------------------------------------- *--------------------------------------
FilterMatch.CmpPtr2CharPtr1Y X.FilterMatch.CmpPtr2CharPtr1Y
lda (ZPFileName),y
phx phx
plx plx
bne .2 Foreign FS or ProDOS.FX : CS compare bne .1 Foreign FS or ProDOS.FX : CS compare
lda (ZPFileName),y jsr X.ToUpper
cmp #'a'
bcc .1
cmp #'z'+1
bcs .1
eor #$20
.1 cmp (ZPPtr2) .1 cmp (ZPPtr2)
rts rts
.2 lda (ZPPtr2)
cmp (ZPFileName),y
rts
*-------------------------------------- *--------------------------------------
FilterMatch.NextPtr2 X.FilterMatch.NextPtr2
inc ZPPtr2 Make PTR2 advance to next char inc ZPPtr2 Make PTR2 advance to next char
bne .1 bne .1
@ -137,22 +130,19 @@ FilterMatch.NextPtr2
.1 lda (ZPPtr2) .1 lda (ZPPtr2)
rts rts
*-------------------------------------- *--------------------------------------
InitSrcDirYA >PUSHYA X.InitSrcDirYA >STYA ZPPtr1
>PUSHWZ Allocate
>SYSCALL RealPath
bcs FilterMatch.RTS
>STYA ZPPtr1 X.InitSrcDirPtr1
txa jsr X.InitGetBuf Get a 256 buffer to store BasePath
>STA.G hFullPath bcs .99
>STA.G hSrcBasePath
ldy #1 ldy #1
lda (ZPPtr1),y lda (ZPPtr2),y
beq .5 we have '/' beq .8 we have '/'
>PUSHW ZPPtr1 jsr X.Init.StatBuf
>PUSHEA.G STATBUF
>SYSCALL Stat
bcs .1 File/DIR does not exists, go extract pattern bcs .1 File/DIR does not exists, go extract pattern
.DO X.ENTER.SUBDIR=1 .DO X.ENTER.SUBDIR=1
@ -169,15 +159,16 @@ InitSrcDirYA >PUSHYA
.1 cmp #MLI.E.INVPATH .1 cmp #MLI.E.INVPATH
beq .11 beq .11
jmp .9 sec
rts
.11 jsr GetPtr1Len TYPE is not DIR, check if wc .11 jsr X.GetPtr2Len TYPE is not DIR, check if wc
dey dey
ldx #0 Init Wildcard count ldx #0 Init Wildcard count
.2 lda (ZPPtr1),y search backward for a / .2 lda (ZPPtr2),y search backward for a /
cmp #'/' cmp #'/'
beq .3 beq .3
@ -192,58 +183,16 @@ InitSrcDirYA >PUSHYA
bne .2 bne .2
.3 txa .3 txa
beq .90 no wc, file not found.... beq .98 no wc, file not found....
.4 jsr GetPtr1Len Search end of string..... .4 jsr X.InitSplitBuf
bcs .99
lda #'/' >STA.G hInclude
.42 dey .8 >LDYA ZPPtr2
cmp (ZPPtr1),y Search backward /
bne .42
tya
sec +1 to skip '/'
adc ZPPtr1
sta ZPPtr2
tay
lda ZPPtr1+1
adc #0
sta ZPPtr2+1
>SYSCALL StrDup
bcs .9
txa
>STA.G hFilter
lda #0
sta (ZPPtr2) cut path at last '/' to remove wildcards
.5 >LDYAI 256
>SYSCALL GetMem Get a 256 buffer to store BasePath
bcs .9
>STYA ZPPtr2
txa
>STA.G hSrcBasePath
jsr StrcpyPtr1ptr2
dey
lda #'/'
cmp (ZPPtr2),y
beq .7
iny
sta (ZPPtr2),y
iny
lda #0
sta (ZPPtr2),y
.7 >LDYA ZPPtr2
>SYSCALL OpenDir >SYSCALL OpenDir
bcs .9 bcs .99
ldy #hDIRs ldy #hDIRs
sta (pData),y set hDIRs[0] = Src Hdir sta (pData),y set hDIRs[0] = Src Hdir
@ -251,22 +200,16 @@ InitSrcDirYA >PUSHYA
lda #1 lda #1
sta (pData),y index=hDIRs[0] sta (pData),y index=hDIRs[0]
jsr .9 Cleanup * clc
clc
rts rts
.90 lda #MLI.E.FNOTFND .98 lda #MLI.E.INVPATH
.9 pha
>LDA.G hFullPath
>SYSCALL FreeMem
pla
sec sec
InitSrcDirYA.RTS .99 rts
rts
*-------------------------------------- *--------------------------------------
ResetSrcDir jsr GethDIR .DO X.RESETSRCDIR=1
X.ResetSrcDir jsr X.GethDIR
>SYSCALL CloseDir >SYSCALL CloseDir
@ -287,92 +230,107 @@ ResetSrcDir jsr GethDIR
* clc * clc
.9 rts .9 rts
.FIN
*-------------------------------------- *--------------------------------------
.DO X.COPY.TO.DEST=1 .DO X.COPY.TO.DEST=1
InitDstDirYA >PUSHYA X.InitDstDirYA >STYA ZPPtr1
>PUSHWZ Allocate
>SYSCALL RealPath
bcs InitSrcDirYA.RTS
>STYA ZPPtr1 X.InitDstDirPtr1
txa jsr X.InitGetBuf Get a 256 buffer to store BasePath
>STA.G hFullPath bcs .99
>PUSHW ZPPtr1 >STA.G hDstBasePath
>PUSHEA.G STATBUF
>SYSCALL Stat jsr X.Init.StatBuf
bcs .1 File/DIR does not exists, go extract DstFileName bcs .1 File/DIR does not exists, go extract DstFileName
>LDA.G STATBUF+S.STAT.MODE+1 >LDA.G STATBUF+S.STAT.MODE+1
and #$F0 and #$F0
cmp /S.STAT.MODE.DIR cmp /S.STAT.MODE.DIR
beq .5 Dst is a directory...no destfilename beq .8 Dst is a directory...no hDstFileName
.1 jsr GetPtr1Len Search end of string..... .1 jsr X.InitSplitBuf
bcs .99
>STA.G hDstFileName
.8 jmp X.NormalizePtr2
.99 rts
.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
rts
.98 plx
pha
txa
>SYSCALL FreeMem
pla
sec
.99 rts
*--------------------------------------
X.Init.StatBuf >PUSHW ZPPtr2
>PUSHEA.G STATBUF
>SYSCALL Stat
rts
*--------------------------------------
X.InitSplitBuf jsr X.GetPtr2Len Search end of string.....
lda #'/' lda #'/'
.2 dey .1 dey
cmp (ZPPtr1),y Search backward / cmp (ZPPtr2),y Search backward /
bne .2 bne .1
tya tya
sec +1 to skip '/' sec +1 to skip '/'
adc ZPPtr1 adc ZPPtr2
sta ZPPtr2 sta ZPPtr1
tay
lda ZPPtr1+1 lda ZPPtr2+1
adc #0 adc #0
sta ZPPtr2+1 sta ZPPtr1+1
lda (ZPPtr1)
beq .8 path is /dir/
>LDYA ZPPtr1
>SYSCALL StrDup >SYSCALL StrDup
bcs .9 bcs .99
txa
>STA.G hDstFileName
lda #0 lda #0
sta (ZPPtr2) sta (ZPPtr1)
.5 >LDYAI 256
>SYSCALL GetMem Get a 256 buffer to store DstBasePath
bcs .9
>STYA ZPPtr2
txa txa
>STA.G hDstBasePath
jsr StrcpyPtr1ptr2 .8 clc
dey .99 rts
lda #'/'
cmp (ZPPtr2),y
beq .7
iny
sta (ZPPtr2),y
iny
lda #0
sta (ZPPtr2),y
.7 jsr .9 Cleanup
clc
rts
.9 pha
>LDA.G hFullPath
>SYSCALL FreeMem
pla
sec
rts
.FIN
*-------------------------------------- *--------------------------------------
GetNextEntry jsr GetEntry X.GetNextEntry jsr X.GetEntry
bcs .9 bcs .9
jsr GetFilenameLen Save actual file len for setting up jsr X.GetFilenameLen Save actual file len for setting up
pha new offset later pha new offset later
lda ZPFileStat lda ZPFileStat
clc clc
@ -383,12 +341,12 @@ GetNextEntry jsr GetEntry
adc /S.STAT adc /S.STAT
sta ZPFileName+1 Make nDIRENTs[i] point to next DIRENT sta ZPFileName+1 Make nDIRENTs[i] point to next DIRENT
jsr GetFilenameLen are we at end of this buffer ? jsr X.GetFilenameLen are we at end of this buffer ?
beq .1 yes, go read next one ... beq .1 yes, go read next one ...
jsr SetFileStatPtr jsr X.SetFileStatPtr
jsr GetoDIRENT jsr X.GetoDIRENT
pla Get back previous file len pla Get back previous file len
sec sec
@ -413,13 +371,13 @@ GetNextEntry jsr GetEntry
rts rts
.1 pla .1 pla
jsr GetEntry.ReadDir jsr X.GetEntry.ReadDir
bcs .9 bcs .9
jsr GetFilenameLen jsr X.GetFilenameLen
beq .99 beq .99
jsr SetFileStatPtr jsr X.SetFileStatPtr
clc clc
.9 rts .9 rts
@ -427,10 +385,10 @@ GetNextEntry jsr GetEntry
.99 sec .99 sec
rts rts
*-------------------------------------- *--------------------------------------
GetEntry jsr GethDIRENT X.GetEntry jsr X.GethDIRENT
bne .1 we have a buffer to scan bne .1 we have a buffer to scan
jsr GetEntry.ReadDir First run, get first block jsr X.GetEntry.ReadDir First run, get first block
bcs .9 ZPFileName = start of buffer bcs .9 ZPFileName = start of buffer
lda (ZPFileName) Empty !!! lda (ZPFileName) Empty !!!
@ -441,7 +399,7 @@ GetEntry jsr GethDIRENT
.1 >SYSCALL GetMemPtr .1 >SYSCALL GetMemPtr
>STYA ZPFileName >STYA ZPFileName
jsr GetoDIRENT jsr X.GetoDIRENT
lda ZPFileName lda ZPFileName
clc clc
@ -454,15 +412,15 @@ GetEntry jsr GethDIRENT
adc (pData),y adc (pData),y
sta ZPFileName+1 ZPFileName=ZPFileName+oDIRENT sta ZPFileName+1 ZPFileName=ZPFileName+oDIRENT
.8 jsr GetFilenameLen .8 jsr X.GetFilenameLen
jsr SetFileStatPtr jsr X.SetFileStatPtr
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
GetEntry.ReadDir X.GetEntry.ReadDir
jsr GethDIRENT jsr X.GethDIRENT
beq .1 beq .1
pha pha
@ -471,7 +429,7 @@ GetEntry.ReadDir
pla pla
>SYSCALL FreeMem discard previous hDIRENT >SYSCALL FreeMem discard previous hDIRENT
.1 jsr GethDIR .1 jsr X.GethDIR
>SYSCALL ReadDir >SYSCALL ReadDir
bcs .9 bcs .9
@ -484,7 +442,7 @@ GetEntry.ReadDir
txa get hDIRENT in A txa get hDIRENT in A
sta (pData),y sta (pData),y
jsr GetoDIRENT jsr X.GetoDIRENT
lda #0 and reset offset for this buffer lda #0 and reset offset for this buffer
sta (pData),y sta (pData),y
@ -493,15 +451,15 @@ GetEntry.ReadDir
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
EnterSubDirYA >STYA ZPPtr2 save SUBDIR for StrCat X.EnterSubDirYA >STYA ZPPtr1 save SUBDIR for StrCat
>LDA.G index >LDA.G index
cmp #X.MAX.RECURSE cmp #X.MAX.RECURSE
beq .9 beq .9
ldy #hSrcBasePath ldy #hSrcBasePath
jsr EnterSubDirY jsr X.EnterSubDirY
>LDYA ZPPtr1 >LDYA ZPPtr2
>SYSCALL OpenDir >SYSCALL OpenDir
bcs .9 bcs .9
@ -521,44 +479,44 @@ EnterSubDirYA >STYA ZPPtr2 save SUBDIR for StrCat
.DO X.COPY.TO.DEST=1 .DO X.COPY.TO.DEST=1
ldy #hDstBasePath ldy #hDstBasePath
jsr EnterSubDirY jsr X.EnterSubDirY
.FIN .FIN
clc clc
.9 rts .9 rts
*--------------------------------------
EnterSubDirY lda (pData),y X.EnterSubDirY lda (pData),y
>SYSCALL GetMemPtr >SYSCALL GetMemPtr
>STYA ZPPtr1 save full path >STYA ZPPtr2 save full path
jsr .1 Make sure ending with /
>PUSHW ZPPtr1
>PUSHW ZPPtr2 >PUSHW ZPPtr2
>PUSHW ZPPtr1
>SYSCALL StrCat >SYSCALL StrCat
.1 jsr GetPtr1Len X.NormalizePtr2 jsr X.GetPtr2Len
dey dey
lda #'/' lda #'/'
cmp (ZPPtr1),y cmp (ZPPtr2),y
beq .8 beq .8
iny iny
sta (ZPPtr1),y sta (ZPPtr2),y
iny iny
lda #0 lda #0
sta (ZPPtr1),y sta (ZPPtr2),y
.8 rts .8 clc
rts
*-------------------------------------- *--------------------------------------
LeaveSubDir >LDA.G index X.LeaveSubDir >LDA.G index
beq .7 beq .7
jsr GethDIRENT.A jsr X.GethDIRENT.A
jsr LeaveSubDir.free jsr X.LeaveSubDir.free
jsr GethDIR jsr X.GethDIR
beq .1 beq .1
pha pha
@ -571,11 +529,11 @@ LeaveSubDir >LDA.G index
bne .8 bne .8
.7 >LDA.G hSrcBasePath .7 >LDA.G hSrcBasePath
jsr LeaveSubDir.free jsr X.LeaveSubDir.free
.DO X.COPY.TO.DEST=1 .DO X.COPY.TO.DEST=1
>LDA.G hDstBasePath >LDA.G hDstBasePath
jsr LeaveSubDir.free jsr X.LeaveSubDir.free
.FIN .FIN
sec sec
@ -584,7 +542,7 @@ LeaveSubDir >LDA.G index
.8 clc .8 clc
rts rts
*-------------------------------------- *--------------------------------------
LeaveSubDir.free X.LeaveSubDir.free
tax tax
beq .8 beq .8
@ -595,51 +553,53 @@ LeaveSubDir.free
.8 rts .8 rts
*-------------------------------------- *--------------------------------------
BasePath.. .DO X.COPY.TO.DEST=1 X.BasePath.. .DO X.COPY.TO.DEST=1
ldy #hDstBasePath ldy #hDstBasePath
jsr BasePath..1 jsr X.BasePath..1
.FIN .FIN
ldy #hSrcBasePath ldy #hSrcBasePath
BasePath..1 lda (pData),y X.BasePath..1 lda (pData),y
>SYSCALL GetMemPtr >SYSCALL GetMemPtr
>STYA ZPPtr1 save full path >STYA ZPPtr2 save full path
jsr GetPtr1Len get len jsr X.GetPtr2Len get len
dey discard ending / dey discard ending /
.2 dey .2 dey
lda (ZPPtr1),y lda (ZPPtr2),y
cmp #'/' cmp #'/'
bne .2 bne .2
iny iny
lda #0 lda #0
sta (ZPPtr1),y cut DIR2/ from /dir1/DIR2/ sta (ZPPtr2),y cut DIR2/ from /dir1/DIR2/
rts rts
*-------------------------------------- *--------------------------------------
GetPtr1Len ldy #$ff X.ToUpper cmp #'a'
bcc .8
cmp #'z'+1
bcs .8
eor #$20
.8 rts
*--------------------------------------
X.GetPtr2Len ldy #$ff
.1 iny .1 iny
lda (ZPPtr1),y get len lda (ZPPtr2),y get len
bne .1 bne .1
rts rts
*-------------------------------------- *--------------------------------------
StrcpyPtr1ptr2 ldy #$ff X.GetFilenameLen
ldy #$ff
.1 iny
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .1
rts
*--------------------------------------
GetFilenameLen ldy #$ff
.1 iny .1 iny
lda (ZPFileName),y lda (ZPFileName),y
@ -648,7 +608,8 @@ GetFilenameLen ldy #$ff
tya tya
rts rts
*-------------------------------------- *--------------------------------------
SetFileStatPtr sec X.SetFileStatPtr
sec
adc ZPFileName adc ZPFileName
sta ZPFileStat sta ZPFileStat
lda ZPFileName+1 lda ZPFileName+1
@ -656,7 +617,7 @@ SetFileStatPtr sec
sta ZPFileStat+1 sta ZPFileStat+1
rts rts
*-------------------------------------- *--------------------------------------
GethDIR >LDA.G index X.GethDIR >LDA.G index
clc clc
adc #hDIRs-1 adc #hDIRs-1
@ -664,15 +625,15 @@ GethDIR >LDA.G index
lda (pData),y lda (pData),y
rts rts
*-------------------------------------- *--------------------------------------
GethDIRENT >LDA.G index X.GethDIRENT >LDA.G index
GethDIRENT.A clc X.GethDIRENT.A clc
adc #hDIRENTs-1 adc #hDIRENTs-1
tay tay
lda (pData),y lda (pData),y
rts rts
*-------------------------------------- *--------------------------------------
GetoDIRENT >LDA.G index X.GetoDIRENT >LDA.G index
asl asl
clc clc
adc #oDIRENTs-1 adc #oDIRENTs-1
@ -681,5 +642,5 @@ GetoDIRENT >LDA.G index
*-------------------------------------- *--------------------------------------
MAN MAN
SAVE usr/src/shared/x.fileenum.s SAVE usr/src/shared/x.fileenum.s
LOAD usr/src/bin/ls.s LOAD usr/src/bin/cp.s
ASM ASM