Back to index

avfs  1.0.1
Functions
zfile.h File Reference
#include "avfs.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

avssize_t av_zfile_pread (struct zfile *fil, struct zcache *zc, char *buf, avsize_t nbyte, avoff_t offset)
int av_zfile_size (struct zfile *fil, struct zcache *zc, avoff_t *sizep)
struct zfileav_zfile_new (vfile *vf, avoff_t dataoff, avuint crc, int calccrc)
struct zcacheav_zcache_new ()
avoff_t av_zcache_size (struct zcache *zc)

Function Documentation

struct zcache* av_zcache_new ( ) [read]

Definition at line 625 of file zread.c.

{
    struct zcache *zc;

    AV_NEW_OBJ(zc, zcache_destroy);
    zc->indexfile = NULL;
    zc->nextindex = INDEXDISTANCE;
    zc->indexes = NULL;
    zc->filesize = 0;
    zc->size = -1;
    zc->crc_ok = 0;
    AV_INITLOCK(zc->lock);

    AV_LOCK(zread_lock);
    if(zread_nextid == 0)
        zread_nextid = 1;

    zc->id = zread_nextid ++;
    AV_UNLOCK(zread_lock);
    
    av_get_tmpfile(&zc->indexfile);
    
    return zc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avoff_t av_zcache_size ( struct zcache zc)

Definition at line 650 of file zread.c.

{
    return zc->filesize;
}

Here is the caller graph for this function:

struct zfile* av_zfile_new ( vfile *  vf,
avoff_t  dataoff,
avuint  crc,
int  calccrc 
) [read]

Definition at line 585 of file zread.c.

{
    int res;
    struct zfile *fil;

    AV_NEW_OBJ(fil, zfile_destroy);
    fil->iseof = 0;
    fil->iserror = 0;
    fil->infile = vf;
    fil->dataoff = dataoff;
    fil->id = 0;
    fil->crc = crc;
    fil->calccrc = calccrc;

    memset(&fil->s, 0, sizeof(z_stream));
    res = inflateInit2(&fil->s, -MAX_WBITS);
    if(res != Z_OK) {
        av_log(AVLOG_ERROR, "ZFILE: inflateInit: %s (%i)",
               fil->s.msg == NULL ? "" : fil->s.msg, res);
        fil->iserror = 1;
    }
    fil->s.adler = 0;

    return fil;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avssize_t av_zfile_pread ( struct zfile fil,
struct zcache zc,
char *  buf,
avsize_t  nbyte,
avoff_t  offset 
)

Definition at line 529 of file zread.c.

{
    avssize_t res;

    if(fil->iserror)
        return -EIO;

    res = av_zfile_do_pread(fil, zc, buf, nbyte, offset);
    if(res < 0)
        fil->iserror = 1;

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_zfile_size ( struct zfile fil,
struct zcache zc,
avoff_t sizep 
)

Definition at line 544 of file zread.c.

{
    int res;
    avoff_t size;

    AV_LOCK(zread_lock);
    size = zc->size;
    AV_UNLOCK(zread_lock);

    if(size != -1 || fil == NULL) {
        *sizep = size;
        return 0;
    }

    fil->id = zc->id;

    res  = zfile_goto(fil, zc, AV_MAXOFF);
    if(res < 0)
        return res;
    
    AV_LOCK(zread_lock);
    size = zc->size;
    AV_UNLOCK(zread_lock);
    
    if(size == -1) {
        av_log(AVLOG_ERROR, "ZFILE: Internal error: could not find size");
        return -EIO;
    }
    
    *sizep = size;
    return 0;

}

Here is the call graph for this function:

Here is the caller graph for this function: