mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-22 03:02:06 +00:00
Use STD*_FILENO constants (#1055)
These are defined in platform.h, but not consistently used Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
This commit is contained in:
@@ -492,7 +492,7 @@ void out_WriteObject(void)
|
|||||||
if (strcmp(objectName, "-") != 0)
|
if (strcmp(objectName, "-") != 0)
|
||||||
f = fopen(objectName, "wb");
|
f = fopen(objectName, "wb");
|
||||||
else
|
else
|
||||||
f = fdopen(1, "wb");
|
f = fdopen(STDOUT_FILENO, "wb");
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
err("Couldn't write file '%s'", objectName);
|
err("Couldn't write file '%s'", objectName);
|
||||||
|
|||||||
@@ -154,9 +154,9 @@ FILE *openFile(char const *fileName, char const *mode)
|
|||||||
if (strcmp(fileName, "-") != 0)
|
if (strcmp(fileName, "-") != 0)
|
||||||
file = fopen(fileName, mode);
|
file = fopen(fileName, mode);
|
||||||
else if (mode[0] == 'r')
|
else if (mode[0] == 'r')
|
||||||
file = fdopen(0, mode);
|
file = fdopen(STDIN_FILENO, mode);
|
||||||
else
|
else
|
||||||
file = fdopen(1, mode);
|
file = fdopen(STDOUT_FILENO, mode);
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
err("Could not open file \"%s\"", fileName);
|
err("Could not open file \"%s\"", fileName);
|
||||||
|
|||||||
@@ -459,7 +459,12 @@ static struct Section *getMainSection(struct Section *section)
|
|||||||
|
|
||||||
void obj_ReadFile(char const *fileName, unsigned int fileID)
|
void obj_ReadFile(char const *fileName, unsigned int fileID)
|
||||||
{
|
{
|
||||||
FILE *file = strcmp("-", fileName) ? fopen(fileName, "rb") : stdin;
|
FILE *file;
|
||||||
|
|
||||||
|
if (strcmp("-", fileName) != 0)
|
||||||
|
file = fopen(fileName, "rb");
|
||||||
|
else
|
||||||
|
file = fdopen(STDIN_FILENO, "rb"); // `stdin` is in text mode by default
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
err("Could not open file %s", fileName);
|
err("Could not open file %s", fileName);
|
||||||
|
|||||||
Reference in New Issue
Block a user