mirror of
https://github.com/bobbimanners/Applecorn.git
synced 2024-09-27 16:55:31 +00:00
Refactoring wildcard code a bit
This commit is contained in:
parent
0c9b5327ae
commit
f534426793
BIN
applecorn.po
BIN
applecorn.po
Binary file not shown.
@ -91,7 +91,7 @@ RENFILE >>> ENTMAIN
|
||||
OFILE >>> ENTMAIN
|
||||
PHA ; Preserve arg for later
|
||||
JSR PREPATH ; Preprocess pathname
|
||||
JSR WILDCARD ; Handle any wildcards
|
||||
JSR WILDONE ; Handle any wildcards
|
||||
JSR EXISTS ; See if file exists ...
|
||||
CMP #$02 ; ... and is a directory
|
||||
BNE :NOTDIR
|
||||
@ -307,7 +307,7 @@ TELL >>> ENTMAIN
|
||||
* A>$1F ProDOS error, translated by FILERET
|
||||
LOADFILE >>> ENTMAIN
|
||||
JSR PREPATH ; Preprocess pathname
|
||||
JSR WILDCARD ; Handle any wildcards
|
||||
JSR WILDONE ; Handle any wildcards
|
||||
JSR EXISTS ; See if it exists ...
|
||||
CMP #$01 ; ... and is a file
|
||||
BEQ :ISFILE
|
||||
@ -644,7 +644,7 @@ CATALOG >>> ENTMAIN
|
||||
LDA MOSFILE ; Length of pathname
|
||||
BEQ :NOPATH ; If zero use prefix
|
||||
JSR PREPATH ; Preprocess pathname
|
||||
JSR WILDCARD ; Handle any wildcards
|
||||
JSR WILDONE ; Handle any wildcards
|
||||
JSR EXISTS ; See if path exists ...
|
||||
CMP #$01 ; ... and is a file
|
||||
BNE :NOTFILE
|
||||
@ -687,7 +687,7 @@ CATALOGRET
|
||||
* Set prefix. Used by *CHDIR to change directory
|
||||
SETPFX >>> ENTMAIN
|
||||
JSR PREPATH ; Preprocess pathname
|
||||
JSR WILDCARD ; Handle any wildcards
|
||||
JSR WILDONE ; Handle any wildcards
|
||||
BCS :ERR
|
||||
LDA #<MOSFILE
|
||||
STA SPFXPL+1
|
||||
@ -730,7 +730,7 @@ DRVINFO >>> ENTMAIN
|
||||
* Filename in MOSFILE, flags in MOSFILE2
|
||||
SETPERM >>> ENTMAIN
|
||||
JSR PREPATH ; Preprocess pathname
|
||||
JSR WILDCARD ; Handle any wildcards
|
||||
JSR WILDONE ; Handle any wildcards
|
||||
BCS :ERR
|
||||
STZ :LFLAG
|
||||
STZ :WFLAG
|
||||
|
@ -3,13 +3,18 @@
|
||||
*
|
||||
* Wildcard support
|
||||
|
||||
* Performs wildcard matching for operations that only require the
|
||||
* first match. <*obj-spec*> in Acorn ADFS terminology.
|
||||
WILDONE JSR WILDCARD
|
||||
JSR CLSDIR
|
||||
RTS
|
||||
|
||||
* Scan path in MOSFILE, break it into segments (ie: chunks delimited
|
||||
* by '/'), and for each segment see if it contains wildcard chars.
|
||||
* If so, pass it to SRCHDIR to expand the wildcard. If not, just
|
||||
* append the segment as it is. Uses MFTEMP to build up the path.
|
||||
* Returns with carry set if wildcard match fails, clear otherwise
|
||||
WILDCARD
|
||||
STZ :LAST
|
||||
WILDCARD STZ :LAST
|
||||
LDX #$00 ; Start with first char
|
||||
STX MFTEMP ; Clear MFTEMP (len=0)
|
||||
PHX
|
||||
@ -103,15 +108,22 @@ APPSEG LDY MFTEMP ; Dest idx = length
|
||||
:DONE STY MFTEMP ; Update length
|
||||
RTS
|
||||
|
||||
* The following is required in order to be able to resume
|
||||
* a directory search
|
||||
WILDFILE DB $00 ; File ref num for open dir
|
||||
WILDIDX DB $00 ; Dirent idx in current block
|
||||
|
||||
* Read directory, apply wildcard match
|
||||
* Inputs: directory name in XY (Pascal string)
|
||||
* If there is a match, replaces SEGBUF with the first match and CLC
|
||||
* If no match, or any other error, returns with carry set
|
||||
* Leaves the directory open to allow resumption of search.
|
||||
SRCHDIR STX OPENPL+1
|
||||
STY OPENPL+2
|
||||
JSR OPENFILE
|
||||
BCS :NODIR
|
||||
LDA OPENPL+5 ; File ref num
|
||||
STA WILDFILE ; Stash for later
|
||||
STA READPL+1
|
||||
:L1 JSR RDFILE ; Read->BLKBUF
|
||||
BCC :S1
|
||||
@ -122,17 +134,21 @@ SRCHDIR STX OPENPL+1
|
||||
BCS :MATCH
|
||||
BRA :L1
|
||||
:MATCH CLC
|
||||
PHP
|
||||
BRA :CLOSE
|
||||
BRA :EXIT
|
||||
:BADDIR
|
||||
:EOF SEC
|
||||
PHP
|
||||
:CLOSE LDA OPENPL+5
|
||||
:EOF
|
||||
:NODIR SEC
|
||||
:EXIT RTS
|
||||
|
||||
* Close directory, if it was open
|
||||
* Preserves flags
|
||||
CLSDIR PHP
|
||||
LDA WILDFILE ; File ref num for open dir
|
||||
BEQ :ALREADY ; Already been closed
|
||||
STA CLSPL+1
|
||||
JSR CLSFILE
|
||||
PLP
|
||||
RTS
|
||||
:NODIR SEC
|
||||
STZ WILDFILE ; Not strictly necessary
|
||||
:ALREADY PLP
|
||||
RTS
|
||||
|
||||
* Apply wildcard match to a directory block
|
||||
@ -153,7 +169,8 @@ SRCHBLK LDA BLKBUF+4 ; Obtain storage type
|
||||
CPX #13 ; Number of dirents in block
|
||||
BNE :L1
|
||||
CLC ; Fell off end, no match
|
||||
:MATCH RTS
|
||||
:MATCH STX WILDIDX ; Record dirent idx for resume
|
||||
RTS
|
||||
|
||||
* Apply wildcard match to a directory entry
|
||||
* On entry: X = dirent index in BLKBUF
|
||||
|
Loading…
Reference in New Issue
Block a user