mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
301 lines
5.5 KiB
Plaintext
301 lines
5.5 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
*/--------------------------------------
|
||
* # FileSearch
|
||
* Search a file in the provided PATH list
|
||
* And return, if found, the full path to it.
|
||
* ## In:
|
||
* PUSHW = Ptr to Search Path (CSTR) %LIB%;/SYS/SLIB
|
||
* PUSHW = Ptr to File Name (CSTR)
|
||
* PUSHW = Ptr to DstBuf
|
||
* PUSHW = Ptr to DstStat
|
||
* ## Out:
|
||
* CC : success
|
||
* DstBuf = FilePath
|
||
* DstStat = S.STAT
|
||
* CS : not found
|
||
*\--------------------------------------
|
||
K.FileSearch >PULLW .4+1 DstStat
|
||
>PULLW .2+1 DstBuf
|
||
jsr K.FileSearch.I
|
||
bcs .9
|
||
|
||
ldx #$ff
|
||
|
||
.1 inx
|
||
lda K.Buf256,x
|
||
.2 sta $ffff,x Self Modified
|
||
bne .1
|
||
|
||
ldx #S.STAT-1
|
||
|
||
.3 lda K.S.STAT,x
|
||
.4 sta $ffff,x Self Modified
|
||
dex
|
||
bpl .3
|
||
.9 rts
|
||
|
||
K.FileSearch.I >PULLW .4+1
|
||
>PULLYA Get Search list
|
||
>SYSCALL ExpandStr.YA Expand it (SYSCALL to BNK2)
|
||
bcs .99
|
||
|
||
stx .98+1
|
||
>STYA .2+1 expanded search list ;
|
||
|
||
stz .1+1
|
||
|
||
.1 ldy #$ff Self Modified Index in Search list string
|
||
|
||
ldx #$0
|
||
|
||
.2 lda $ffff,y Self Modified, Search list string
|
||
beq .3 end of string, try it....
|
||
iny
|
||
cmp #';'
|
||
beq .3
|
||
sta K.Buf256,x
|
||
inx
|
||
bra .2
|
||
|
||
.3 txa
|
||
beq .98 String is empty....nothing to try
|
||
|
||
sty .1+1 save current index
|
||
|
||
ldy #$0
|
||
|
||
.4 lda $ffff,y Self Modified, Append Fiename...
|
||
sta K.Buf256,x
|
||
beq .5
|
||
iny
|
||
inx
|
||
bra .4
|
||
|
||
.5 stz K.Buf256+1,x set string ending 0
|
||
|
||
>PUSHWI K.S.STAT
|
||
>PUSHWI K.Buf256
|
||
jsr K.STAT
|
||
bcs .1 Failed...retry next path...
|
||
|
||
jsr .98 Discard Expanded hSrch list
|
||
|
||
clc
|
||
rts
|
||
|
||
.98 lda #$ff SELF MODIFIED : Discard Expanded hSrch list
|
||
jsr K.FreeMem.A
|
||
lda #MLI.ERR.FNOTFND
|
||
sec
|
||
.99 rts
|
||
*/--------------------------------------
|
||
* # GetFullPath.YA
|
||
* ## In :
|
||
* Y,A = Filename (C-String)
|
||
* ## Out :
|
||
* CC : success
|
||
* Y,A = FullPath (C-String)
|
||
* X = hMem of FullPath
|
||
* CS : A = Error Code
|
||
*\--------------------------------------
|
||
K.GetFullPath.YA
|
||
>STYA ZPPtr1
|
||
ldx #0
|
||
|
||
lda (ZPPtr1)
|
||
beq .8
|
||
|
||
cmp #'/' full path starting with '/'?
|
||
beq .2 yes, do not append to current prefix
|
||
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
jsr K.GetMemPtr.A
|
||
>STYA ZPPtr2
|
||
|
||
ldy #0
|
||
|
||
.1 lda (ZPPtr2),y
|
||
beq .2
|
||
sta K.Buf256,x
|
||
iny
|
||
inx
|
||
bne .1
|
||
|
||
.2 ldy #0
|
||
|
||
.3 lda (ZPPtr1),y
|
||
beq .8
|
||
sta K.Buf256,x
|
||
iny
|
||
inx
|
||
bne .3
|
||
|
||
.8 stz K.Buf256,x
|
||
>LDYAI K.Buf256
|
||
jsr K.NewStr.YA
|
||
rts
|
||
*/--------------------------------------
|
||
* # LoadFile
|
||
* ## In:
|
||
* PUSHW = AUXTYPE (Handled by....
|
||
* PUSHB = TYPE ...
|
||
* PUSHB = MODE ...
|
||
* PUSHW = PATH ...FOpen)
|
||
* ## Out:
|
||
* Y,A = File Length
|
||
* X = hMem of Loaded File
|
||
*\--------------------------------------
|
||
K.LoadFile lda (pStack) read PTR.LO on top of stack
|
||
pha
|
||
ldy #1
|
||
lda (pStack),y read PTR.HI on top of stack
|
||
pha
|
||
>PUSHWI K.S.STAT
|
||
pla
|
||
ply
|
||
>PUSHYA
|
||
jsr K.Stat
|
||
bcs .10
|
||
|
||
lda K.S.STAT+S.STAT.SIZE+3
|
||
ora K.S.STAT+S.STAT.SIZE+2
|
||
bne .11
|
||
|
||
>LDYA K.S.STAT+S.STAT.SIZE push len
|
||
jsr K.GetMem.YA
|
||
bcs .10
|
||
>STYA K.LoadFile.Mem
|
||
stx K.LoadFile.hMem
|
||
|
||
jsr K.FOpen
|
||
bcs .9
|
||
sta K.LoadFile.hFile
|
||
|
||
>PUSHW K.LoadFile.Mem
|
||
>PUSHW K.S.STAT+S.STAT.SIZE
|
||
>PUSHB K.LoadFile.hFile
|
||
jsr K.FRead
|
||
bcs .97
|
||
|
||
phy
|
||
pha Save Bytes read
|
||
|
||
jsr .99
|
||
|
||
pla
|
||
ply
|
||
ldx K.LoadFile.hMem
|
||
clc
|
||
.9 rts
|
||
|
||
.11 lda #SYSMGR.ERRFTB
|
||
.10 pha
|
||
>POP 6
|
||
pla
|
||
sec
|
||
rts
|
||
|
||
.97 pha
|
||
lda K.LoadFile.hMem
|
||
jsr K.FreeMem.A
|
||
pla
|
||
|
||
.99 pha
|
||
lda K.LoadFile.hFile
|
||
jsr K.FClose.A
|
||
pla
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
K.LoadFile.hFile .BS 1
|
||
K.LoadFile.hMem .BS 1
|
||
K.LoadFile.Mem .BS 2
|
||
*/--------------------------------------
|
||
* # SaveFile
|
||
* ## In:
|
||
* PUSHW = SrcPtr
|
||
* PUSHW = SrcLen
|
||
* PUSHW = AUXTYPE (Handled by....
|
||
* PUSHB = TYPE ...
|
||
* PUSHB = MODE ...
|
||
* PUSHW = PATH ...FOpen)
|
||
*\--------------------------------------
|
||
K.SaveFile jsr K.FOpen
|
||
bcs .9
|
||
|
||
sta .90+1
|
||
|
||
>PUSHA
|
||
jsr K.FWrite
|
||
bcs .99
|
||
|
||
jsr .99
|
||
clc
|
||
rts
|
||
|
||
.99 pha
|
||
.90 lda #$ff
|
||
jsr K.FClose.A
|
||
pla
|
||
sec
|
||
rts
|
||
|
||
.9 pha
|
||
>POP 4 Discard SrcPtr & SrcLen
|
||
pla
|
||
sec
|
||
rts
|
||
*/--------------------------------------
|
||
* # ChTyp
|
||
* ## In:
|
||
* PUSHB = TYPE
|
||
* PUSHW = PATH
|
||
*\--------------------------------------
|
||
K.ChTyp jsr PFT.CheckPathSTK
|
||
>PULLW K.MLI.PARAMS+1
|
||
>PULLB .1+1
|
||
>MLICALL MLIGETFILEINFO
|
||
bcs .9
|
||
|
||
.1 lda #$ff
|
||
sta K.MLI.PARAMS+S.FILEINFO.TYPE
|
||
>MLICALL MLISETFILEINFO
|
||
.9 rts
|
||
*/--------------------------------------
|
||
* # ChMod
|
||
* ## In:
|
||
* PUSHW = UID
|
||
* PUSHW = PATH
|
||
*\--------------------------------------
|
||
K.ChMod
|
||
sec
|
||
rts
|
||
*/--------------------------------------
|
||
* # ChOwn
|
||
* ## In:
|
||
* PUSHW = UID
|
||
* PUSHW = PATH
|
||
*\--------------------------------------
|
||
K.ChOwn
|
||
sec
|
||
rts
|
||
*/--------------------------------------
|
||
* # ChGrp
|
||
* ## In:
|
||
* PUSHW = GID
|
||
* PUSHW = PATH
|
||
*\--------------------------------------
|
||
K.ChGrp
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/SYS/KERNEL.S.FIO
|
||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||
ASM
|