forked from lda/telodendria
Add StreamFile() convenience method.
This commit is contained in:
parent
e0a3760a37
commit
8539a03d5b
2 changed files with 18 additions and 10 deletions
25
src/Stream.c
25
src/Stream.c
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -36,6 +36,9 @@ extern Stream *
|
|||
extern Stream *
|
||||
StreamFd(int);
|
||||
|
||||
extern Stream *
|
||||
StreamFile(FILE *);
|
||||
|
||||
extern Stream *
|
||||
StreamOpen(const char *, const char *);
|
||||
|
||||
|
|
Loading…
Reference in a new issue