2003-02-14 18:17:17 +00:00
|
|
|
#ifndef __ruamoko_qfile_h
|
|
|
|
#define __ruamoko_qfile_h
|
|
|
|
|
[qfcc] Add a handle type for engine resources
I never liked the various hacks I had come up with for representing
resource handles in Ruamoko. Structs with an int were awkward to test,
pointers and ints could be modified, etc etc. The new @handle keyword (@
used to keep handle free for use) works just like struct, union and
enum in syntax, but creates an opaque type suitable for a 32-bit handle.
The backing type is a function so v6 progs can use it without (all the
necessary opcodes exist) and no modifications were needed for
type-checking in binary expressions, but only assignment and comparisons
are supported, and (of course) nil. Tested using cbuf_t and QFile: seems
to work as desired.
I had considered 64-bit handles, but really, if more than 4G resource
objects are needed, I'm not sure QF can handle the game. However, that
limit is per resource manager, not total.
2023-05-25 01:41:28 +00:00
|
|
|
typedef @handle _qfile_t QFile;
|
2003-02-14 18:17:17 +00:00
|
|
|
|
2011-03-25 07:46:32 +00:00
|
|
|
@extern int Qrename (string old, string new);
|
|
|
|
@extern int Qremove (string path);
|
2010-12-01 23:04:18 +00:00
|
|
|
@extern QFile Qopen (string path, string mode);
|
|
|
|
@extern void Qclose (QFile file);
|
|
|
|
@extern string Qgetline (QFile file);
|
2011-03-25 07:46:32 +00:00
|
|
|
@extern string Qreadstring (QFile file, int len);
|
|
|
|
@extern int Qread (QFile file, void *buf, int count);
|
|
|
|
@extern int Qwrite (QFile file, void *buf, int count);
|
|
|
|
@extern int Qputs (QFile file, string str);
|
|
|
|
//@extern int Qgets (QFile file, void *buf, int count);
|
|
|
|
@extern int Qgetc (QFile file);
|
|
|
|
@extern int Qputc (QFile file, int c);
|
|
|
|
@extern int Qseek (QFile file, int offset, int whence);
|
|
|
|
@extern int Qtell (QFile file);
|
|
|
|
@extern int Qflush (QFile file);
|
|
|
|
@extern int Qeof (QFile file);
|
|
|
|
@extern int Qfilesize (QFile file);
|
2003-02-14 18:17:17 +00:00
|
|
|
|
|
|
|
#endif//__ruamoko_qfile_h
|