30FILE *
fopen_e(
char *file,
char *open_mode,
long mode) {
32 static char buffer[1024];
34 if ((mode & FOPEN_SAVE_IF_EXISTS) &&
fexists(file)) {
35 sprintf(buffer,
"%s~", file);
36 if (rename(file, buffer) != 0) {
37 fprintf(stderr,
"error: cannot save previous version of %s--new file not opened.\n", file);
38 if (mode & FOPEN_RETURN_ON_ERROR)
44 if ((fp = fopen(file, open_mode))) {
45 if (mode & FOPEN_INFORM_OF_OPEN)
46 printf(
"%s opened in mode %s\n", file, open_mode);
50 sprintf(buffer,
"unable to open %s in mode %s", file, open_mode);
53 if (!(mode & FOPEN_RETURN_ON_ERROR))
FILE * fopen_e(char *file, char *open_mode, long mode)
Opens a file with error checking, messages, and aborts.