Bug 904768 - Print filename when failing to open files in libmar; r=netzen

This commit is contained in:
Mike Shal 2013-08-13 15:18:03 -04:00
parent 4b034e5a50
commit d7b8a090f4
3 changed files with 20 additions and 4 deletions

View File

@ -79,8 +79,11 @@ static int mar_concat_file(FILE *fp, const char *path) {
int rv = 0;
in = fopen(path, "rb");
if (!in)
if (!in) {
fprintf(stderr, "ERROR: could not open file in mar_concat_file()\n");
perror(path);
return -1;
}
while ((len = fread(buf, 1, BLOCKSIZE, in)) > 0) {
if (fwrite(buf, len, 1, fp) != 1) {

View File

@ -48,8 +48,11 @@ static int mar_test_callback(MarFile *mar, const MarItem *item, void *unused) {
#else
fd = creat(item->name, item->flags);
#endif
if (fd == -1)
if (fd == -1) {
fprintf(stderr, "ERROR: could not create file in mar_test_callback()\n");
perror(item->name);
return -1;
}
fp = fdopen(fd, "wb");
if (!fp)

View File

@ -168,8 +168,11 @@ MarFile *mar_open(const char *path) {
FILE *fp;
fp = fopen(path, "rb");
if (!fp)
if (!fp) {
fprintf(stderr, "ERROR: could not open file in mar_open()\n");
perror(path);
return NULL;
}
return mar_fpopen(fp);
}
@ -179,8 +182,11 @@ MarFile *mar_wopen(const wchar_t *path) {
FILE *fp;
_wfopen_s(&fp, path, L"rb");
if (!fp)
if (!fp) {
fprintf(stderr, "ERROR: could not open file in mar_wopen()\n");
_wperror(path);
return NULL;
}
return mar_fpopen(fp);
}
@ -367,6 +373,8 @@ read_product_info_block(char *path,
MarFile mar;
mar.fp = fopen(path, "rb");
if (!mar.fp) {
fprintf(stderr, "ERROR: could not open file in read_product_info_block()\n");
perror(path);
return -1;
}
rv = mar_read_product_info_block(&mar, infoBlock);
@ -547,6 +555,8 @@ int get_mar_file_info(const char *path,
int rv;
FILE *fp = fopen(path, "rb");
if (!fp) {
fprintf(stderr, "ERROR: could not open file in get_mar_file_info()\n");
perror(path);
return -1;
}