Ignore:
Timestamp:
Jun 15, 2008, 3:50:06 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Implement cucul_file_tell().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/file.c

    r2406 r2407  
    4444    z_stream stream;
    4545    gzFile gz;
    46     int eof, zip;
     46    int eof, zip, total;
    4747#   endif
    4848    FILE *f;
     
    5858    cucul_file_t *fp = malloc(sizeof(*fp));
    5959
    60     fp->readonly = !strchr(mode, 'r');
     60    fp->readonly = strchr(mode, 'r');
    6161
    6262#   if defined HAVE_ZLIB_H
     
    7373    fp->eof = 0;
    7474    fp->zip = 0;
     75    fp->total = 0;
    7576
    7677    if(fp->readonly)
     
    141142}
    142143
     144uint64_t cucul_file_tell(cucul_file_t *fp)
     145{
     146#if defined __KERNEL__
     147    return 0;
     148#elif defined HAVE_ZLIB_H
     149    if(fp->zip)
     150        return fp->total;
     151    return gztell(fp->gz);
     152#else
     153    return ftell(fp->f);
     154#endif
     155}
     156
    143157size_t cucul_file_read(cucul_file_t *fp, void *ptr, size_t size)
    144158{
     
    162176    return 0;
    163177#elif defined HAVE_ZLIB_H
     178    /* FIXME: zip files are not supported */
    164179    return gzwrite(fp->gz, ptr, size);
    165180#else
     
    247262        {
    248263            fp->eof = 1;
     264            fp->total += total_read;
    249265            return total_read;
    250266        }
     
    254270    }
    255271
     272    fp->total += total_read;
    256273    return total_read;
    257274}
Note: See TracChangeset for help on using the changeset viewer.