diff --git a/Quake/common.c b/Quake/common.c index 67904323..ad880bd2 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -2084,3 +2084,19 @@ int FS_ferror(fshandle_t *fh) return ferror(fh->file); } +char *FS_fgets(char *s, int size, fshandle_t *fh) +{ + char *ret; + + if (FS_feof(fh)) + return NULL; + + if (size > (fh->length - fh->pos) + 1) + size = (fh->length - fh->pos) + 1; + + ret = fgets(s, size, fh->file); + fh->pos = ftell(fh->file) - fh->start; + + return ret; +} + diff --git a/Quake/common.h b/Quake/common.h index c47848af..2c1a867d 100644 --- a/Quake/common.h +++ b/Quake/common.h @@ -242,6 +242,7 @@ void FS_rewind(fshandle_t *fh); int FS_feof(fshandle_t *fh); int FS_ferror(fshandle_t *fh); int FS_fclose(fshandle_t *fh); +char *FS_fgets(char *s, int size, fshandle_t *fh); extern struct cvar_s registered;