Back to index

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

Go to the source code of this file.

Functions

int _zip_set_name (struct zip *za, int idx, const char *name)

Function Documentation

int _zip_set_name ( struct zip za,
int  idx,
const char *  name 
)

Definition at line 44 of file zip_set_name.c.

{
    char *s;
    int i;
    
    if (idx < 0 || idx >= za->nentry || name == NULL) {
       _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
       return -1;
    }

    if ((i=_zip_name_locate(za, name, 0, NULL)) != -1 && i != idx) {
       _zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
       return -1;
    }

    /* no effective name change */
    if (i == idx)
       return 0;
    
    if ((s=strdup(name)) == NULL) {
       _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
       return -1;
    }
    
    if (za->entry[idx].state == ZIP_ST_UNCHANGED) 
       za->entry[idx].state = ZIP_ST_RENAMED;

    free(za->entry[idx].ch_filename);
    za->entry[idx].ch_filename = s;

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: