From c8fa7998838199d1f1d3ae7ec94fcad58515fa02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Mon, 15 Jan 2018 20:28:36 +0000 Subject: [PATCH] Output error msg when object file can't be opened MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In rgbasm, output a fatal error if the destination object file can't be opened. Signed-off-by: Antonio Niño Díaz --- src/asm/output.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/asm/output.c b/src/asm/output.c index 678b4a30..47f8c969 100644 --- a/src/asm/output.c +++ b/src/asm/output.c @@ -522,31 +522,36 @@ void out_WriteObject(void) addexports(); + /* If no path specified, don't write file */ + if (tzObjectname == NULL) + return; + f = fopen(tzObjectname, "wb"); - if (f != NULL) { - struct PatchSymbol *pSym; - struct Section *pSect; + if (f == NULL) + fatalerror("Couldn't write file '%s'\n", tzObjectname); - fwrite(RGBDS_OBJECT_VERSION_STRING, 1, - strlen(RGBDS_OBJECT_VERSION_STRING), f); + struct PatchSymbol *pSym; + struct Section *pSect; - fputlong(countsymbols(), f); - fputlong(countsections(), f); + fwrite(RGBDS_OBJECT_VERSION_STRING, 1, + strlen(RGBDS_OBJECT_VERSION_STRING), f); - pSym = pPatchSymbols; - while (pSym) { - writesymbol(pSym->pSymbol, f); - pSym = pSym->pNext; - } + fputlong(countsymbols(), f); + fputlong(countsections(), f); - pSect = pSectionList; - while (pSect) { - writesection(pSect, f); - pSect = pSect->pNext; - } - - fclose(f); + pSym = pPatchSymbols; + while (pSym) { + writesymbol(pSym->pSymbol, f); + pSym = pSym->pNext; } + + pSect = pSectionList; + while (pSect) { + writesection(pSect, f); + pSect = pSect->pNext; + } + + fclose(f); } /*