lisp-take-1/parse/istream/file/new.c

40 lines
539 B
C

#include <assert.h>
#include <fcntl.h>
#include <debug.h>
#include "../new.h"
#include "inheritance.h"
#include "struct.h"
#include "new.h"
struct istream* new_file_istream(
const char* input_file)
{
ENTER;
struct file_istream* this = (void*) new_istream(
&file_istream_inheritance,
sizeof(*this));
int fd = open(input_file, O_RDONLY);
if (fd < 0)
{
TODO;
}
this->fd = fd;
this->i = 0;
this->n = 0;
EXIT;
return (void*) this;
}