]> git.draconx.ca Git - upkg.git/commitdiff
Add EOF notification to the upkg export API.
authorNick Bowler <nbowler@draconx.ca>
Wed, 10 Jun 2009 21:30:52 +0000 (17:30 -0400)
committerNick Bowler <nbowler@draconx.ca>
Wed, 10 Jun 2009 21:53:31 +0000 (17:53 -0400)
src/libupkg.c
src/upkg.h

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;
 }
index 2e92e8527c1570e78be20bb8fa14792041a5b39f..7ef55d74e5fe0f2cfe2b9350dd7dfd12cde6dbb8 100644 (file)
@@ -55,6 +55,8 @@ struct upkg {
 struct upkg_file {
        const char *name;
 
+       int eof;
+
        struct upkg *pkg;
        unsigned long base, offset, len;
 };