Top |
This section describes an extension to Glk for various Unix functions. It was written by Andrew Plotkin for the Glk libraries CheapGlk and GlkTerm.
You can put other startup code in glkunix_startup_code()
. This should
generally be limited to finding and opening data files. There are a few Unix
Glk library functions which are convenient for this purpose.
strid_t glkunix_stream_open_pathname_gen (char *pathname
,glui32 writemode
,glui32 textmode
,glui32 rock
);
Opens an arbitrary file for reading or writing. (You cannot open a file for
appending using this call.) Note that this function is
only available during glkunix_startup_code()
. It is
inherently non-portable; it should not and cannot be called from inside
glk_main()
.
strid_t glkunix_stream_open_pathname (char *pathname
,glui32 textmode
,glui32 rock
);
This opens a file for reading. It is a less-general form of
glkunix_stream_open_pathname_gen()
, preserved for backwards compatibility.
This should be used only by glkunix_startup_code()
.
void
glkunix_set_base_file (char *filename
);
Sets the library's idea of the “current directory” for the executing program.
The argument should be the name of a file (not a directory).
When this is set, glk_fileref_create_by_name()
will create files in the same
directory as that file, and glk_fileref_create_by_prompt()
will base default
filenames off of the file.
If this is not called, the library works in the Unix current working
directory, and picks reasonable default defaults.