mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Merge pull request #610 from daid/stdin
Allow rgbasm and rgblink to use stdout and stdin as input and output
This commit is contained in:
@@ -471,7 +471,11 @@ static void registerExportedSymbol(struct Symbol *symbol, void *arg)
|
||||
*/
|
||||
void out_WriteObject(void)
|
||||
{
|
||||
FILE *f = fopen(tzObjectname, "wb");
|
||||
FILE *f;
|
||||
if (strcmp(tzObjectname, "-") != 0)
|
||||
f = fopen(tzObjectname, "wb");
|
||||
else
|
||||
f = fdopen(1, "wb");
|
||||
|
||||
if (!f)
|
||||
err(1, "Couldn't write file '%s'", tzObjectname);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -126,7 +127,13 @@ FILE *openFile(char const *fileName, char const *mode)
|
||||
if (!fileName)
|
||||
return NULL;
|
||||
|
||||
FILE *file = fopen(fileName, mode);
|
||||
FILE *file;
|
||||
if (strcmp(fileName, "-") != 0)
|
||||
file = fopen(fileName, mode);
|
||||
else if (mode[0] == 'r')
|
||||
file = fdopen(0, mode);
|
||||
else
|
||||
file = fdopen(1, mode);
|
||||
|
||||
if (!file)
|
||||
err(1, "Could not open file \"%s\"", fileName);
|
||||
|
||||
Reference in New Issue
Block a user