X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2F_PDCLIB_seek.c;fp=functions%2Fstdio%2F_PDCLIB_seek.c;h=5a3f982bab000dd8f991b892251edf7f6a8ba072;hb=c5d49235e09fbd58416f10dec2799e61cf3431c8;hp=0000000000000000000000000000000000000000;hpb=4c7c56442f6b3e08c17594dd4e8095fca3aec9cf;p=pdclib diff --git a/functions/stdio/_PDCLIB_seek.c b/functions/stdio/_PDCLIB_seek.c new file mode 100644 index 0000000..5a3f982 --- /dev/null +++ b/functions/stdio/_PDCLIB_seek.c @@ -0,0 +1,39 @@ +/* int64_t _PDCLIB_seek( FILE *, int64_t, int ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#include +#include +#ifndef REGTEST + +int_fast64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t offset, + int whence ) +{ + int_fast64_t newPos; + if(!stream->ops->seek(stream->handle, offset, whence, &newPos)) { + return EOF; + } + + stream->ungetidx = 0; + stream->bufidx = 0; + stream->bufend = 0; + stream->pos.offset = newPos; + return newPos; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + /* Testing covered by ftell.c */ + return TEST_RESULTS; +} + +#endif +