]> git.draconx.ca Git - liblbx.git/blobdiff - src/lbx.c
liblbx: Rename lbx_stat to lbx_file_stat.
[liblbx.git] / src / lbx.c
index 17bf9769f0a670d938b67ed516e0043574543a25..0e26315fc8652acdc922a7f526140d5288463ab9 100644 (file)
--- a/src/lbx.c
+++ b/src/lbx.c
@@ -1,7 +1,7 @@
 /*
  *  2ooM: The Master of Orion II Reverse Engineering Project
  *  Library for working with LBX archive files.
- *  Copyright (C) 2006-2008 Nick Bowler
+ *  Copyright (C) 2006-2010 Nick Bowler
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -190,19 +190,20 @@ size_t lbx_numfiles(struct lbx_state *lbx)
        return lbx->nfiles;
 }
 
-int lbx_stat(struct lbx_state *lbx, size_t index, struct lbx_statbuf *buf)
+int
+lbx_file_stat(struct lbx_state *lbx, unsigned fileno, struct lbx_statbuf *buf)
 {
        static char str[256]; /* FIXME */
 
-       if (index >= lbx->nfiles) {
+       if (fileno >= lbx->nfiles) {
                buf->name = NULL;
                lbx_errno = LBX_ERANGE;
                return -1;
        }
 
-       snprintf(str, sizeof str, "%s.%03zu", lbx->name, index);
+       snprintf(str, sizeof str, "%s.%03u", lbx->name, fileno);
        buf->name = str;
-       buf->size = lbx->offsets[index+1] - lbx->offsets[index];
+       buf->size = lbx->offsets[fileno+1] - lbx->offsets[fileno];
        return 0;
 }
 
@@ -293,6 +294,8 @@ int lbx_file_seek(struct lbx_file_state *f, long offset, int whence)
        f->lbx->last_file = NULL;
        if (fops->seek(f->lbx->f, f->base + pos, SEEK_SET) != 0)
                return -1;
+
+       f->offset = pos;
        f->lbx->last_file = f;
        f->eof = 0;