rgblink: improve file open error messages

This commit is contained in:
bentley
2010-01-18 16:47:08 -07:00
parent aea1990de3
commit 02ba30f8e0
2 changed files with 16 additions and 7 deletions

View File

@@ -1,7 +1,9 @@
#include <err.h> #include <err.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sysexits.h>
#include "asmotor.h" #include "asmotor.h"
@@ -19,8 +21,9 @@ SetMapfileName(char *name)
{ {
mf = fopen(name, "w"); mf = fopen(name, "w");
if (!mf) if (mf == NULL)
errx(5, "Unable to open mapfile for writing"); errx(EX_CANTCREAT, "Cannot open mapfile '%s' : %s", name,
strerror(errno));
} }
void void
@@ -28,8 +31,9 @@ SetSymfileName(char *name)
{ {
sf = fopen(name, "w"); sf = fopen(name, "w");
if (!sf) if (sf == NULL)
errx(5, "Unable to open symfile for writing"); errx(EX_CANTCREAT, "Cannot open symfile '%' : %s", name,
strerror(errno));
fprintf(sf, ";File generated by xLink v" LINK_VERSION "\n\n"); fprintf(sf, ";File generated by xLink v" LINK_VERSION "\n\n");
} }

View File

@@ -4,9 +4,11 @@
*/ */
#include <err.h> #include <err.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sysexits.h>
#include "link/mylink.h" #include "link/mylink.h"
#include "link/main.h" #include "link/main.h"
@@ -443,9 +445,9 @@ obj_Readfile(char *tzObjectfile)
oReadLib = 0; oReadLib = 0;
pObjfile = fopen(tzObjectfile, "rb"); pObjfile = fopen(tzObjectfile, "rb");
if (!pObjfile) { if (pObjfile == NULL)
errx(5, "Unable to open '%s'", tzObjectfile); errx(EX_NOINPUT, "Unable to open object '%s' : %s",
} tzObjectfile, strerror(errno));
obj_ReadOpenFile(pObjfile, tzObjectfile); obj_ReadOpenFile(pObjfile, tzObjectfile);
fclose(pObjfile); fclose(pObjfile);
@@ -493,6 +495,9 @@ lib_Readfile(char *tzLibfile)
oReadLib = 1; oReadLib = 1;
pObjfile = fopen(tzLibfile, "rb"); pObjfile = fopen(tzLibfile, "rb");
if (pObjfile == NULL)
errx(EX_NOINPUT, "Unable to open object '%s' : %s",
tzObjectfile, strerror(errno));
if (!pObjfile) { if (!pObjfile) {
errx(5, "Unable to open '%s'", tzLibfile); errx(5, "Unable to open '%s'", tzLibfile);
} }