A2osX/SYS/KERNEL.S.STAT.txt

203 lines
3.8 KiB
Plaintext
Raw Normal View History

PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
INC 1
AUTO 6
*/--------------------------------------
* # Stat
* Return information about a file
* ## In :
* PUSHW = PTR to S.STAT buffer
* PUSHW = PTR to Filename (C-String)
* ## Out :
*\--------------------------------------
K.Stat jsr PFT.CheckPathSTK
jsr STDIO.PullMLIPath
>PULLW K.Stat.StoreY+1
>MLICALL MLIGETFILEINFO
bcs .9
ldx K.MLI.PARAMS+S.FILEINFO.ACCESS
lda #S.STAT.MODE.XO+S.STAT.MODE.WO+S.STAT.MODE.RO
cpx #S.FILEINFO.ACCESS.FULL
beq .2
lda #S.STAT.MODE.XO+S.STAT.MODE.RO
cpx #S.FILEINFO.ACCESS.R
beq .2
lda #0
.2 ldy #S.STAT.MODE
jsr K.Stat.StoreY
ldx #K.Stat.DST-K.Stat.SRC
.3 ldy K.Stat.SRC-1,x
lda K.MLI.PARAMS,y
ldy K.Stat.DST-1,x
jsr K.Stat.StoreY
dex
bne .3
ldy #S.STAT.SIZE
lda #0
jsr K.Stat.StoreY
iny
lda K.MLI.PARAMS+S.FILEINFO.BLOCKSUSED
asl
jsr K.Stat.StoreY
iny
lda K.MLI.PARAMS+S.FILEINFO.BLOCKSUSED+1
rol
jsr K.Stat.StoreY
iny
lda #0
rol
jsr K.Stat.StoreY
clc
.9 rts
K.Stat.StoreY sta $ffff,y
rts
*--------------------------------------
K.Stat.SRC .DA #S.FILEINFO.TYPE
.DA #S.FILEINFO.AUXTYPE,#S.FILEINFO.AUXTYPE+1
.DA #S.FILEINFO.BLOCKSUSED,#S.FILEINFO.BLOCKSUSED+1
K.Stat.DST .DA #S.STAT.P.TYPE
.DA #S.STAT.P.AUXTYPE,#S.STAT.P.AUXTYPE+1
.DA #S.STAT.BLOCKS,#S.STAT.BLOCKS+1
*/-------------------------------------
* # MKDirYA
* ## In:
* Y,A = DIR name
* ## Out:
* CC : success
* CS : error
* A = EC
*\-------------------------------------
K.MKDir.YA jsr PFT.CheckPathYA
jsr STDIO.SetMLIPathYA
lda #S.FILEINFO.ACCESS.FULL
sta K.MLI.PARAMS+S.FILEINFO.ACCESS
lda #S.FILEINFO.TYPE.DIR
sta K.MLI.PARAMS+S.FILEINFO.TYPE
lda #S.FILEINFO.STORETYPE.DIR
sta K.MLI.PARAMS+S.FILEINFO.STORETYPE
* jsr DATETIME
ldx #3
.1 lda DATELO,x
sta K.MLI.PARAMS+8,x
dex
bpl .1
>MLICALL MLICREATE
rts
*/--------------------------------------
* # MkNod.YA
* return a hFile for a given Device Name
* ## IN:
* Y,A=DevName
* ## OUT:
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MkNod.YA jsr K.GetDevByName.YA Ptr1=NAME
bcs .9
>STYA pDev
stx .1+1
ldy #S.DEV.S
lda (pDev),y
bit #S.DEV.S.BLOCK
bne .99
txa Pass DEV.ID to OPEN
ldx #DEVMGR.OPEN
jsr pDevJmp
bcs .9
>LDYAI S.NODE.DEV
jsr K.GetMem0.YA
bcs .9
>STYA ZPPtr3 Ptr3=S.NODE
ldy #S.NODE.T
lda #S.NODE.T.CDEV
sta (ZPPtr3),y
ldy #S.NODE.DEV.ID
.1 lda #$ff Self Modified
sta (ZPPtr3),y
ldy #S.NODE.DEV.JMP
lda pDev
sta (ZPPtr3),y
iny
lda pDev+1
sta (ZPPtr3),y
txa
clc
.9 rts
.99 lda #MLI.ERR.IO
sec
rts
*/--------------------------------------
* # MKFIFO
* return a S.FILE to a new FIFO
* ## IN:
* ## OUT:
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MKFIFO >LDYAI 256
jsr K.GetMem.YA
bcs .99
stx .1+1 save FIFO buffer
>LDYAI S.NODE.FIFO
jsr K.GetMem0.YA
bcs .9
>STYA ZPPtr1
ldy #S.NODE.T
lda #S.NODE.T.FIFO
sta (ZPPtr1),y
iny S.NODE.FIFO.hMem
.1 lda #$ff Self Modified
sta (ZPPtr1),y
txa
clc
rts
.9 pha save error code
lda .1+1 get back FIFO buffer
jsr K.FreeMem.A
pla
sec
.99 rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.STAT
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM