120 |
| Try to close file PTR, and print an error message if fails. | |
| Try to close file PTR, and print an error message if fails. | |
121 |
`-------------------------------------------------------------*/ |
`-------------------------------------------------------------*/ |
122 |
|
|
123 |
int |
void |
124 |
xfclose (FILE *ptr) |
xfclose (FILE *ptr) |
125 |
{ |
{ |
|
int result; |
|
|
|
|
126 |
if (ptr == NULL) |
if (ptr == NULL) |
127 |
return 0; |
return; |
128 |
|
|
129 |
result = fclose (ptr); |
if (ferror (ptr)) |
130 |
if (result == EOF) |
error (EXIT_FAILURE, 0, _("I/O error")); |
|
error (EXIT_FAILURE, errno, _("cannot close file")); |
|
131 |
|
|
132 |
return result; |
if (fclose (ptr) != 0) |
133 |
|
error (EXIT_FAILURE, errno, _("cannot close file")); |
134 |
} |
} |
135 |
|
|
136 |
|
|