Improve return value checking and error handling.

This commit is contained in:
Jon Siwek 2013-09-24 17:38:22 -05:00
parent 4b24cebad9
commit daf5d0d098
14 changed files with 101 additions and 33 deletions

View file

@ -935,7 +935,7 @@ static const char* check_for_dir(const char* filename, bool load_pkgs)
return copy_string(filename);
}
FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs)
static FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs)
{
filename = check_for_dir(filename, load_pkgs);
@ -944,6 +944,13 @@ FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs
FILE* f = fopen(filename, "r");
if ( ! f )
{
char buf[256];
strerror_r(errno, buf, sizeof(buf));
reporter->Error("Failed to open file %s: %s", filename, buf);
}
delete [] filename;
return f;