qdosmsq:traps:trap_2:open

IO_OPEN/IOA_OPEN

This trap allows a file to be opened.

Call ParametersReturn Parameters
D0.B$01D0.LError code (see below)
D1.LJob id of job to own the file.
-1 = current job.
D1.LPreserved
D3.LOpen type (See below)D3.LPreserved
A0.LPointer to file name in QDOS format.A0.LChannel ID for opened file.
ERR_NJInvalid job id.
ERR_OMOut of memory.
ERR_NOChannel not open.
ERR_NFFile or device not found.
ERR_EXFile already exists.
ERR_IUFile in use.
ERR_BNBad file or device name.

D3.L should be one of the following open type keys on entry :

0OPEN.
1OPEN_IN.
2OPEN_NEW.
3OPEN_OVER. Not available on microdrives.
4OPEN_DIR.
Channel IDConnects to an already opened PIPE with the supplied id.
  • All registers not shown above are not used on entry and are preserved on exit, except :
    • D2.L is supposed to be preserved but according to an article in December 1986 QL World, this may not always be the case.
    • A1.L is corrupted if TRAP #4 was called prior to this trap call.

The following shows the use of this call to open and close a file :

        moveq   #io_open,d0       ; Trap code
        moveq   #-1,d1            ; The current job will own the file
        moveq   #0,d3             ; SuperBasic OPEN mode
        lea     name,a0           ; Pointer to name of file
        trap    #2                ; Open the file
        tst.l   d0                ; Test for errors
        bne.s   error             ; Oops, an error occurred

        ; Now do stuff here with the channel id in A0.L.

        moveq   #io_close,d0      ; Trap code
        trap    #2                ; Close the file (Channel ID in A0.L)

        ; Usually we ignore errors in D0, if any, and carry on.
        ; More code goes here.

name    dc.w    4                 ; Length of filename
        dc.b    'CON_'            ; Bytes of actual filename
  • qdosmsq/traps/trap_2/open.txt
  • Last modified: 2008/06/25 14:04
  • by norman