OpenFile.c



FILE *OpenFile(char *filename, char *envvar, char *mode, BOOL *noenv)

Inputs

char *filename Filename to be opened
char *envvar Unix/MS-DOS environment variable Other OS assign name (with :)
char *mode Mode in which to open file (r, w, etc)

Outputs

BOOL *noenv Set to TRUE under Unix/MS-DOS if the reason for failure was that the environment variable was not set.

Returns

FILE * File pointer or NULL on failure

Description

Attempts to open a filename as specified. Returns a file pointer. If this fails:

Under UNIX/MS-DOS: gets the contents of the envvar environment variable and prepends that to the filename and tries again. If envvar was not set, noenv is set to TRUE and the routine returns a NULL pointer.

Under other OSs: prepends the envvar string onto the filename and tries to open the file again.

Returns the pointer returned by the open() command after all this.

Created: 22.09.94 Last Modified: 09.03.95