@@ -507,8 +507,7 @@ class FileHandler {
507507 ){
508508 this ->ae = ae;
509509 this ->logger = logger;
510- f = fopen (filename.c_str (), mode.c_str ());
511- closed = false ;
510+ f = ampl_fopen (filename.c_str (), mode.c_str ());
512511
513512 if (f == NULL ){
514513 std::string log_msg = " FileHandler: could not open " + filename;
@@ -517,9 +516,7 @@ class FileHandler {
517516 }
518517 };
519518 ~FileHandler (){
520- if (!closed){
521- fclose (f);
522- }
519+ close ();
523520 };
524521 void ampl_fprintf (const char *format, ...){
525522
@@ -534,9 +531,20 @@ class FileHandler {
534531 };
535532 };
536533
534+ FILE* ampl_fopen (const char * filename, const char * mode){
535+ return ae->Fopen (filename, mode);
536+ };
537+
538+ int ampl_fclose (FILE * stream){
539+ int res = ae->Fclose (stream);
540+ return res;
541+ };
542+
537543 void close (){
538- fclose (f);
539- closed = true ;
544+ if (f){
545+ ampl_fclose (f);
546+ f = NULL ;
547+ }
540548 };
541549};
542550
@@ -1044,6 +1052,15 @@ class Connector {
10441052 // These functions should be used instead of of standart library ones to prevent errors derived
10451053 // from diferent compiler implementations.
10461054
1055+ FILE* ampl_fopen (const char * filename, const char * mode){
1056+ return ae->Fopen (filename, mode);
1057+ };
1058+
1059+ int ampl_fclose (FILE * stream){
1060+ int res = ae->Fclose (stream);
1061+ return res;
1062+ };
1063+
10471064 int ampl_fprintf (FILE *stream, const char *format, ...){
10481065
10491066 va_list va;
0 commit comments