GLYLIB
0.3.0b
|
00001 // Function written by B. Lachele Foley, 2007 00002 #include <mylib.h> 00003 //#include "../inc/mylib.h" 00004 00005 /************** myfopen(const char,const char) ****************/ 00006 FILE* myfopen(const char *myfilename,const char *myopentype){ 00007 FILE *MYFP; 00008 MYFP=fopen(myfilename,myopentype); 00009 if(MYFP==NULL){ 00010 printf("Error opening file.\n"); 00011 printf("Expected location is:\n\n"); 00012 printf("\t%s\n\n",myfilename); 00013 printf("Attempted file open for %s\n",myopentype); 00014 printf("Exiting.\n"); 00015 exit(1); 00016 } 00017 return MYFP; 00018 } 00019 00020 00021 /************** myfreopen(const char,const char,FILE *) ****************/ 00022 /* This function is useful when the open status of a file is not know. 00023 The freopen function will attempt to "close" the file, but will ignore 00024 any close errors (such as the file not being open) and then (re)open it. */ 00025 FILE* myfreopen(const char *myfilename,const char *myopentype, FILE *alreadyopen){ 00026 FILE *MYFP; 00027 MYFP=freopen(myfilename,myopentype,alreadyopen); 00028 if(MYFP==NULL){ 00029 printf("Error opening file.\n"); 00030 printf("Expected location is:\n\n"); 00031 printf("\t%s\n\n",myfilename); 00032 printf("Attempted file open for %s\n",myopentype); 00033 printf("Exiting.\n"); 00034 exit(1); 00035 } 00036 return MYFP; 00037 }