FILE/DOR API (Work In Progress)

This commit is contained in:
Rémy GIBERT 2016-09-01 17:42:38 +02:00
parent e00d74623c
commit c70fa8bf7c
3 changed files with 152 additions and 23 deletions

View File

@ -538,19 +538,19 @@ S.STAT.MODE.RU .EQ $0100
S.STAT.MODE.SST .EQ $0200 S.STAT.MODE.SST .EQ $0200
S.STAT.MODE.SGID .EQ $0400 S.STAT.MODE.SGID .EQ $0400
S.STAT.MODE.SUID .EQ $0800 S.STAT.MODE.SUID .EQ $0800
S.STAT.DEV .EQ 2 S.STAT.DEV .EQ 2 WORD
S.STAT.UID .EQ 4 S.STAT.UID .EQ 4 WORD
S.STAT.GID .EQ 6 S.STAT.GID .EQ 6 WORD
S.STAT.INO .EQ 8 S.STAT.INO .EQ 8 QWORD
S.STAT.NLINK .EQ 16 S.STAT.NLINK .EQ 16 WORD
S.STAT.SIZE .EQ 24 S.STAT.SIZE .EQ 18 DWORD
S.STAT.ATIME .EQ 32 DWORD S.STAT.ATIME .EQ 22 DWORD
S.STAT.MTIME .EQ 36 DWORD S.STAT.MTIME .EQ 26 DWORD
S.STAT.CTIME .EQ 40 DWORD S.STAT.CTIME .EQ 30 DWORD
S.STAT.BLOCKS .EQ 48 S.STAT.BLOCKS .EQ 34 DWORD
S.STAT.BLKSIZE .EQ 56 S.STAT.BLKSIZE .EQ 38 WORD
* *
S.STAT .EQ 64 S.STAT .EQ 40
*-------------------------------------- *--------------------------------------
* S.FILE for FOPEN,FREAD...... * S.FILE for FOPEN,FREAD......
*-------------------------------------- *--------------------------------------
@ -574,16 +574,19 @@ S.FILE.PRODOS .EQ 4
* S.DIR for OpenDir,ReadDir,CloseDir * S.DIR for OpenDir,ReadDir,CloseDir
*-------------------------------------- *--------------------------------------
S.DIR.HANDLER .EQ 0 S.DIR.HANDLER .EQ 0
S.DIR.INO .EQ 1
S.DIR.PATH .EQ 2 PSTR S.DIR.PRODOS.REF .EQ 2
S.DIR.PRODOS.IOBUF .EQ 3
S.DIR.PRODOS .EQ 4
* no S.DIR * no S.DIR
*-------------------------------------- *--------------------------------------
* S.DIRENT for ReadDir * S.DIRENT for ReadDir
*-------------------------------------- *--------------------------------------
S.DIRENT
S.DIRENT.STAT .EQ 0 S.DIRENT.STAT .EQ 0
S.DIRENT.NAME .EQ S.STAT PSTR S.DIRENT.NAME .EQ S.STAT
* no S.DIRENT,Variable size *
S.DIRENT.PRODOS .EQ S.STAT+16 PSTR (LEN+15 MAX)
*-------------------------------------- *--------------------------------------
S.PFT.PATH .EQ 0 S.PFT.PATH .EQ 0
S.PFT.HANDLER .EQ 23 S.PFT.HANDLER .EQ 23

View File

@ -13,31 +13,156 @@ AUTO 6
* CS : A = EC * CS : A = EC
*-------------------------------------- *--------------------------------------
S.OPENDIRYA jsr S.PFTCHECKPATHYA S.OPENDIRYA jsr S.PFTCHECKPATHYA
>STYA ZPQuickPtr2
>STYA MLICALL.PARAMS+1 For MLIOPEN
>PUSHWI S.DIR.PRODOS
>PUSHBI S.MEM.F.INIT0
jsr S.GetMem
bcs .9
>STYA ZPQuickPtr1
stx hDIR
lda (ZPQuickPtr2)
cmp #1 One char ?
bne .7 No, Go open dir....
tay Y=1
lda (ZPQuickPtr2),y
cmp #'/' Root required ?
beq .8 Yes, Go for ONLINE Call (S.DIR.PRODOS.REF=0)
lda #SYSMGR.ERRSYN
sec
.9 rts
.7 >PUSHWI 1024 get a ProDOS IOBUF
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
jsr S.GetMem
bcs .98
>STYA MLICALL.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
txa
ldy #S.DIR.PRODOS.IOBUF
sta (ZPQuickPtr1),y
>MLICALL MLIOPEN
bcs .98
lda MLICALL.PARAMS+5 get ref_num
ldy #S.DIR.PRODOS.REF
sta (ZPQuickPtr1),y
.8 lda hDIR
clc clc
rts rts
.98 pha save MLI error
jsr S.CLOSEDIRA.1
pla get back MLI error
sec
.99 rts
*--------------------------------------
hDIR .BS 1
*-------------------------------------- *--------------------------------------
* In : * In :
* A = hDIR * A = hDIR
* Out : * Out :
* CC : Y,A = PTR to S.DIRENT * CC : X = hDIREND, Y,A = PTR to S.DIRENT
* CS : A = EC * CS : A = EC, A = 0 : no more entry
*-------------------------------------- *--------------------------------------
S.READDIRA jsr S.PFTCHECKDIRA S.READDIRA jsr S.PFTCHECKDIRA
jsr S.GetMemPtrA
>STYA ZPQuickPtr1
ldy #S.DIR.PRODOS.REF
lda (ZPQuickPtr1),y
bne .
>PUSHWI 256 Get Buffer for ONLINE call
>PUSHBI 0
jsr S.GetMem
bcs .99
>STYA ZPQuickPtr2
stx hONLINE
stz MLICALL.PARAMS+1
>STYA MLICALL.PARAMS+2
>MLICALL MLIONLINE
bcs .
lda #1 Ending 0
sta BufSize
stz BufSize+1
ldy #0
.1 lda (ZPQuickPtr2),y
and #$0F
beq .2
sec Add Filelen +1
adc BufSize
sta BufSize
lda #0
adc BufSize
sta BufSize
lda #S.STAT
adc BufSize
sta BufSize
lda /S.STAT
adc BufSize+1
sta BufSize+1
inx
.2 tya
clc clc
rts adc #16
tay
bcc .1
txa
beq .99 A=0, CS no more DIRENT
>PUSHW BufSize
>PUSHBI 0
jsr S.GetMem
bcs .98
>STYA ZPQuickPtr3
.98 pha
lda hONLINE
jsr S.FreeMemA
pla
sec
.99 rts
*-------------------------------------- *--------------------------------------
* In : * In :
* A = hDIR * A = hDIR
*-------------------------------------- *--------------------------------------
S.CLOSEDIRA jsr S.PFTCHECKDIRA S.CLOSEDIRA jsr S.PFTCHECKDIRA
sta hDIR
jsr S.GetMemPtrA
>STYA ZPQuickPtr1
S.CLOSEDIRA.1 ldy #S.DIR.PRODOS.REF
lda (ZPQuickPtr1),y
beq .1
sta MLICALL.PARAMS+1
>MLICALL MLICLOSE
.1 ldy #S.DIR.PRODOS.IOBUF
lda (ZPQuickPtr1),y
beq .2
jsr S.FreeMemA
.2 lda hDIR
jsr S.FreeMemA
clc clc
rts rts
*-------------------------------------- *--------------------------------------
hONLINE .BS 1
BufSize .BS 2
*-------------------------------------- *--------------------------------------
MAN MAN
SAVE SYS/KERNEL.S.DIR SAVE SYS/KERNEL.S.DIR

View File

@ -59,7 +59,7 @@ S.FOPEN jsr S.PFTCHECKPATHSTK
>PUSHWI 1024 get a ProDOS IOBUF >PUSHWI 1024 get a ProDOS IOBUF
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE >PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
jsr S.GetMem jsr S.GetMem
bcs .99 bcs .98
>STYA MLICALL.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call >STYA MLICALL.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
txa txa
@ -115,6 +115,7 @@ hFILE .BS 1
* A = hFILE * A = hFILE
*-------------------------------------- *--------------------------------------
S.FCLOSEA jsr S.PFTCHECKFILEA S.FCLOSEA jsr S.PFTCHECKFILEA
sta hFILE
jsr S.GetMemPtrA jsr S.GetMemPtrA
>STYA ZPQuickPtr1 >STYA ZPQuickPtr1