Create filestream_eof

This commit is contained in:
twinaphex 2016-06-03 07:29:27 +02:00
parent d40eade52c
commit a503db016e
2 changed files with 14 additions and 0 deletions

View File

@ -69,6 +69,8 @@ char *filestream_getline(RFILE *stream);
int filestream_getc(RFILE *stream);
int filestream_eof(RFILE *stream);
bool filestream_write_file(const char *path, const void *data, ssize_t size);
int filestream_putc(RFILE *stream, int c);

View File

@ -361,6 +361,18 @@ error:
return -1;
}
int filestream_eof(RFILE *stream)
{
ssize_t current_position = filestream_tell(stream);
ssize_t end_position = filestream_seek(stream, 0, SEEK_END);
filestream_seek(stream, current_position, SEEK_SET);
if (current_position >= end_position)
return 1;
return 0;
}
ssize_t filestream_tell(RFILE *stream)
{
if (!stream)