X-Git-Url: http://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/67988e9de2e9002064d52b4a1c5b5c4f8e6e665f..6637b91cdb7b3d3e923f3d72e36be07e9009e7e8:/src/libupkg.c diff --git a/src/libupkg.c b/src/libupkg.c index f2addc9..4bb13a3 100644 --- a/src/libupkg.c +++ b/src/libupkg.c @@ -474,8 +474,14 @@ int upkg_export_seek(struct upkg_file *f, long offset, int whence) break; } - if (rc == 0) + if (rc == 0) { f->pkg->priv->last_file = f; + f->offset = offset; + f->eof = 0; + } else if (f->pkg->priv->last_file == f) { + f->pkg->priv->last_file = NULL; + } + return rc; } @@ -495,5 +501,8 @@ size_t upkg_export_read(struct upkg_file *f, void *buf, size_t n) rc = fread(buf, 1, want, f->pkg->priv->f); f->offset += rc; + + if (want < n || rc < want && feof(f->pkg->priv->f)) + f->eof = 1; return rc; }