home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / m / makealf / Source / s / finfo next >
Text File  |  1996-11-24  |  2KB  |  66 lines

  1. ; s.finfo
  2. ; routine to grab file information using OS_File 17
  3. ; OS_File 23 would be better, but isn't RO2-friendly
  4. ; NB this does NOT fill in all fields of a fileinfo structure;
  5. ; it only fills in addrs, misc, length, attributes, type.
  6. ; Returns object type (thus 0 for non-existent).
  7. ; Returns 0 if the OS_File call returns an error.
  8. ;
  9. ; also included is a routine to split filename into directory & objname
  10. ; (non-destructively)
  11. ;
  12. ; int finfo(char *name, fileinfo *fblock);
  13. ; void fnsplit(const char *name, char *dbuf, char *nbuf);
  14.  
  15.         GET h.asmregs
  16.  
  17.         GET h.asmSWIs
  18.  
  19.         AREA |A$$code|, CODE, READONLY
  20.  
  21.         EXPORT finfo
  22.         EXPORT fnsplit
  23.  
  24. finfo    STMFD sp!,{r4,r5,lr}
  25.     MOV ip,r1        ; place to fill in information
  26.     MOV r1,r0        ; filename
  27.     MOV r0,#17        ; magic number: read catalogue info, no path
  28.     SWI XOS_Bit+SWI_OS_File
  29.     STMIA ip!,{r2-r5}    ; load, exec, length, attr
  30.     STR r0,[ip]        ; object type
  31.     MOVVS r0,#0
  32.     LDMFD sp!,{r4,r5,pc}^
  33.  
  34. fnsplit STMFD sp!,{r4,r5,lr}
  35.         MOV r4,#0
  36.         STRB r4,[r1]
  37. fnloop1 LDRB r3,[r0,r4]
  38.         CMP r3,#0
  39.         ADDNE r4,r4,#1
  40.         BNE fnloop1
  41. fnloop2 SUBS r4,r4,#1
  42.         BLT nodot
  43.         LDRB r3,[r0,r4]
  44.         CMP r3,#'.'
  45.         BEQ dot
  46.         CMP r3,#':'
  47.         BNE fnloop2
  48.         ADD r5,r4,#1
  49.         MOV r3,#0
  50.         STRB r3,[r1,r5]
  51.         B fnloop3
  52. dot     MOV r5,r4
  53.         MOV r3,#0
  54.         STRB r3,[r1,r5]
  55. fnloop3 SUBS r5,r5,#1
  56.         BLT nodot
  57.         LDRB r3,[r0,r5]
  58.         STRB r3,[r1,r5]
  59.         B fnloop3
  60. nodot   ADD r4,r4,#1
  61.         LDRB r3,[r0,r4]
  62.         STRB r3,[r2],#1
  63.         CMP r3,#0
  64.         BNE nodot
  65.         LDMFD sp!,{r4,r5,pc}^
  66.