Back to index

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

Go to the source code of this file.

Functions

 zip_add_dir (struct zip *za, const char *name)

Function Documentation

zip_add_dir ( struct zip za,
const char *  name 
)

Definition at line 44 of file zip_add_dir.c.

{
    int len, ret;
    char *s;
    struct zip_source *source;

    if (name == NULL) {
       _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
       return -1;
    }

    s = NULL;
    len = strlen(name);

    if (name[len-1] != '/') {
       if ((s=(char *)malloc(len+2)) == NULL) {
           _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
           return -1;
       }
       strcpy(s, name);
       s[len] = '/';
       s[len+1] = '\0';
    }

    if ((source=zip_source_buffer(za, NULL, 0, 0)) == NULL) {
       free(s);
       return -1;
    }
       
    ret = _zip_replace(za, -1, s ? s : name, source);

    free(s);
    if (ret < 0)
       zip_source_free(source);

    return ret;
}

Here is the call graph for this function: