Entry | |
---|---|
R0 | Pointer to file descriptor (held in the RMA if R2 = 0 on entry) |
R1 | Pointer to filename (held in the RMA if R2 = 0 on entry) |
R2 | Pointer to buffer to hold the file data, or value of 0 (allocate some space in RMA, or use file directly if possible) |
Exit | |
---|---|
- | - |
This SWI is used to open a message-file. If R2 = 0, then the data-structure in R0 and the filename in R1 both must be in the RMA.
An application may decide that it would like to buffer the file in its own workspace (rather than the RMA) if it needs to be loaded, or use the file directly if it is already in memory. To do this:
SYS "MessageTrans_FileInfo",,filename$ TO flags%,,size% IF flags% AND 1 THEN buffer%=0 ELSE buffer%=FNalloc(size%) SYS "OS_Module",6,,,17+LENfilename$ TO ,,filedesc% $(filedesc%+16)=filename$ SYS "MessageTrans_OpenFile",filedesc%,filedesc%+16,buffer%
where FNalloc() allocates a buffer of a given size, by using the Wimp_SlotSize or “END=” command. In fact the filename and file descriptor only need to be in the RMA if R2=0 on entry to MessageTrans_OpenFile.