[Ohrrpgce] SVN: teeemcee/7996 Add OPENFILE() replacement for OPEN, for compatibility with FB 0.24+.

subversion at HamsterRepublic.com subversion at HamsterRepublic.com
Wed May 4 08:44:50 PDT 2016


teeemcee
2016-05-04 08:44:50 -0700 (Wed, 04 May 2016)
1717
Add OPENFILE() replacement for OPEN, for compatibility with FB 0.24+.

Not used yet (see next commit). This commit already removes the old
OPEN hook, which only worked on FB 0.23 and older.

  dim fh as integer = FREEFILE
  OPEN filename FOR BINARY ACCESS READ as #fh

becomes

  dim fh as integer
  OPENFILE(file, FOR_BINARY + ACCESS_READ, fh)

The other possible open modes are FOR_INPUT, FOR_OUTPUT, FOR_APPEND,
ACCESS_WRITE, ACCESS_READ_WRITE, ACCESS_ANY. You can even pass 0 as
the flags to get the default (FOR BINARY ACCESS READ WRITE).  Not
supported are ENCODING, LEN, LOCK or FOR RANDOM (none of which we
use).  Also, the default ACCESS is ACCESS READ WRITE unlike OPEN which
defaults to ACCESS ANY. I thought that ACCESS ANY is a bit strange;
better to use ACCESS READ if you don't care about write access. I also
think that FOR RANDOM is best avoided. ENCODING may be genuinely
useful in future but will be a nuisance to support, and won't be
needed for reading unicode text from RELOAD lumps.

Also, like the functional form of OPEN, the program won't abort on
error when compiled with -exx, which is a nice improvement.
The other difference is that fh is BYREF and FREEFILE is called
automatically.

You can continue to use OPEN (as well as OPEN PIPE, OPEN CONS, etc)
when you are sure that the file being opened doesn't need to be hooked
(i.e. is not an .rpg lump). Currently if you accidently use OPEN the
worst that can happen is that some live-previewing feature harmlessly
breaks, but in future OPENFILE will also support reading lumps from a
lumped (or possibly even compressed, on Android) .rpg.

Ensured the FB headers are up to date and also compatible with 0.23.
Removed unneeded fb/fb_error.h
---
U   wip/SConscript
D   wip/fb/fb_error.h
U   wip/fb/fb_stub.h
U   wip/fb/readme.txt
U   wip/filelayer.cpp
U   wip/filelayer.h
U   wip/lumpfile.bas
U   wip/lumpfile.bi


More information about the Ohrrpgce mailing list