Add StreamFile() convenience method.

This commit is contained in:
Jordan Bancino 2023-03-16 16:25:24 +00:00
parent e0a3760a37
commit 8539a03d5b
2 changed files with 18 additions and 10 deletions

View file

@ -97,17 +97,9 @@ StreamFd(int fd)
}
Stream *
StreamOpen(const char *path, const char *mode)
StreamFile(FILE *fp)
{
FILE *fp = fopen(path, mode);
Io *io;
if (!fp)
{
return NULL;
}
io = IoFile(fp);
Io *io = IoFile(fp);
if (!io)
{
@ -117,6 +109,19 @@ StreamOpen(const char *path, const char *mode)
return StreamIo(io);
}
Stream *
StreamOpen(const char *path, const char *mode)
{
FILE *fp = fopen(path, mode);
if (!fp)
{
return NULL;
}
return StreamFile(fp);
}
int
StreamClose(Stream * stream)
{

View file

@ -36,6 +36,9 @@ extern Stream *
extern Stream *
StreamFd(int);
extern Stream *
StreamFile(FILE *);
extern Stream *
StreamOpen(const char *, const char *);