X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffsetpos.c;h=4820f73b3ddf89b0d2014bd3a25cc9fccdabde20;hb=393020b6e48719d27699dea6b29e53025bbd5123;hp=e40be0b948cb1a36bc38d9388081349e06f8e2a2;hpb=e5112b619d1aae8ffc439389cfcbd3b2b4bd2454;p=pdclib diff --git a/functions/stdio/fsetpos.c b/functions/stdio/fsetpos.c index e40be0b..4820f73 100644 --- a/functions/stdio/fsetpos.c +++ b/functions/stdio/fsetpos.c @@ -9,10 +9,22 @@ #include #ifndef REGTEST +#include <_PDCLIB_glue.h> -int fsetpos( struct _PDCLIB_file_t * stream, const _PDCLIB_fpos_t * pos ) +int fsetpos( struct _PDCLIB_file_t * stream, const struct _PDCLIB_fpos_t * pos ) { - /* TODO: Implement. */ + if ( stream->status & _PDCLIB_FWRITE ) + { + if ( _PDCLIB_flushbuffer( stream ) == EOF ) + { + return EOF; + } + } + if ( _PDCLIB_seek( stream, pos->offset, SEEK_SET ) == EOF ) + { + return EOF; + } + stream->pos.status = pos->status; return 0; }