home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
m
/
makealf
/
Source
/
s
/
finfo
next >
Wrap
Text File
|
1996-11-24
|
2KB
|
66 lines
; s.finfo
; routine to grab file information using OS_File 17
; OS_File 23 would be better, but isn't RO2-friendly
; NB this does NOT fill in all fields of a fileinfo structure;
; it only fills in addrs, misc, length, attributes, type.
; Returns object type (thus 0 for non-existent).
; Returns 0 if the OS_File call returns an error.
;
; also included is a routine to split filename into directory & objname
; (non-destructively)
;
; int finfo(char *name, fileinfo *fblock);
; void fnsplit(const char *name, char *dbuf, char *nbuf);
GET h.asmregs
GET h.asmSWIs
AREA |A$$code|, CODE, READONLY
EXPORT finfo
EXPORT fnsplit
finfo STMFD sp!,{r4,r5,lr}
MOV ip,r1 ; place to fill in information
MOV r1,r0 ; filename
MOV r0,#17 ; magic number: read catalogue info, no path
SWI XOS_Bit+SWI_OS_File
STMIA ip!,{r2-r5} ; load, exec, length, attr
STR r0,[ip] ; object type
MOVVS r0,#0
LDMFD sp!,{r4,r5,pc}^
fnsplit STMFD sp!,{r4,r5,lr}
MOV r4,#0
STRB r4,[r1]
fnloop1 LDRB r3,[r0,r4]
CMP r3,#0
ADDNE r4,r4,#1
BNE fnloop1
fnloop2 SUBS r4,r4,#1
BLT nodot
LDRB r3,[r0,r4]
CMP r3,#'.'
BEQ dot
CMP r3,#':'
BNE fnloop2
ADD r5,r4,#1
MOV r3,#0
STRB r3,[r1,r5]
B fnloop3
dot MOV r5,r4
MOV r3,#0
STRB r3,[r1,r5]
fnloop3 SUBS r5,r5,#1
BLT nodot
LDRB r3,[r0,r5]
STRB r3,[r1,r5]
B fnloop3
nodot ADD r4,r4,#1
LDRB r3,[r0,r4]
STRB r3,[r2],#1
CMP r3,#0
BNE nodot
LDMFD sp!,{r4,r5,pc}^