GN_Opf, Open file/resource (wildcard search)

Register parameters

RST 20H, DEFW $6009
IN:
     HL = 0,1,2; not allowed (B=0)
     BHL = pointer to name of filename to open
     (B = 0, identified as local pointer)

     DE = 0,1,2; not allowed
     DE = pointer to space to insert explicit filename
     C = maximum space to fill with this explicit filename (e.g. 18)

     A = access mode
          OP_IN ($01)  = open for input
          OP_OUT ($02) = open for output
          OP_UP ($03)  = open for update (read/write)
          OP_MEM ($04) = open memory (internal usage - not for applications)
          OP_DIR ($05) = create directory - returns DOR handle
          OP_DOR ($06) = return DOR information - returns DOR handle

OUT, if call successful:
     Fc = 0
     IX = file handle for open file
     A(IN=OP_DOR): A = DOR type; DN_FIL, DN_EPR, Dn_DIR, etc.
     B = number of segments in the explicit filename
     C = number of characters in returned, expanded filename at (DE)
     DE = points beyond the last character of explicit filename

OUT, if call failed:
     Fc = 1
     A = error code:
          RC_BAD ($04), bad arguments
          RC_IVF ($17), invalid filename, eg. ".wrong"
          RC_ONF ($12), file not found
          RC_USE ($15), file already in use
          RC_FTM ($18), file type mismatch
          RC_UNK ($03), unknown request, eg. A(in) invalid

Registers changed after return:
     ......HL/..IY same
     AFBCDE../IX.. different 

Notes

Please refer to GN_Fex for details of what might happen to the filename. Using GN_Opf with A=OP_DOR, you only get a DOR handle. The file is not opened. If the file exists, OS_Dor & A=DR_FRE must be used to release the DOR handle before the file is opened/created with GN_Opf, otherwise RC_USE ("file in use") is returned.

Related calls

GN_Cl, close file
GN_Del, delete a file from memory
GN_Ren, rename file
OS_Cl, internal close (OZ usage)
OS_Del, file delete (internal OZ usage)
OS_Frm, file read miscellaneous
OS_Fwm, file write miscellaneous
OS_Gb, get byte from file (or device)
OS_Gbt, get byte from file (or device) with timeout
OS_Mv, move bytes between stream and memory
OS_Op, internal open (OZ usage)
OS_Pb, write byte to file, device
OS_Pbt, write byte to file, device with timeout
OS_Ren, file rename (internal OZ usage)