]> git.draconx.ca Git - upkg.git/blobdiff - src/libupkg.c
Add EOF notification to the upkg export API.
[upkg.git] / src / libupkg.c
index f2addc9447a4ea6105f55572644d3904adf899a1..8072516120a0bed5da998bd82b3a0e08f77b442f 100644 (file)
@@ -474,8 +474,13 @@ 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->eof = 0;
+       } else if (f->pkg->priv->last_file == f) {
+               f->pkg->priv->last_file = NULL;
+       }
+
        return rc;
 }
 
@@ -495,5 +500,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;
 }