Back to index

php5  5.3.10
Functions
zip_name_locate.c File Reference
#include <string.h>
#include "zipint.h"

Go to the source code of this file.

Functions

 zip_name_locate (struct zip *za, const char *fname, int flags)
int _zip_name_locate (struct zip *za, const char *fname, int flags, struct zip_error *error)

Function Documentation

int _zip_name_locate ( struct zip za,
const char *  fname,
int  flags,
struct zip_error error 
)

Definition at line 51 of file zip_name_locate.c.

{
    int (*cmp)(const char *, const char *);
    const char *fn, *p;
    int i, n;

    if (fname == NULL) {
       _zip_error_set(error, ZIP_ER_INVAL, 0);
       return -1;
    }

    if((flags & ZIP_FL_UNCHANGED)  && !za->cdir) {
       return -1;
    }

    cmp = (flags & ZIP_FL_NOCASE) ? strcmpi : strcmp;

    n = (flags & ZIP_FL_UNCHANGED) ? za->cdir->nentry : za->nentry;
    for (i=0; i<n; i++) {
       if (flags & ZIP_FL_UNCHANGED)
           fn = za->cdir->entry[i].filename;
       else
           fn = _zip_get_name(za, i, flags, error);

       /* newly added (partially filled) entry */
       if (fn == NULL)
           continue;

       if (flags & ZIP_FL_NODIR) {
           p = strrchr(fn, '/');
           if (p)
              fn = p+1;
       }

       if (cmp(fname, fn) == 0)
           return i;
    }

/* Look for an entry should not raise an error  */
/*    _zip_error_set(error, ZIP_ER_NOENT, 0);*/
    return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

zip_name_locate ( struct zip za,
const char *  fname,
int  flags 
)

Definition at line 43 of file zip_name_locate.c.

{
    return _zip_name_locate(za, fname, flags, &za->error);
}

Here is the call graph for this function:

Here is the caller graph for this function: