TopographyFile::~TopographyFile() { if (IsEmpty()) return; ClearCache(); msShapefileClose(&file); if (dir != NULL) { --dir->refcount; zzip_dir_free(dir); } }
/** => zzip_dir_creat * * If the third argument "ext" has another special meaning here, as it * is used to ensure that a given zip-file is created with the first entry * of the ext-list appended as an extension unless the file-path already * ends with a file-extension registered in the list. Therefore {"",0} * matches all files and creates them as zip-archives under the given * nonmodified name. (Some magic here? If the path ends in the path * separator then make a real directory even in the presence of ext-list?) * * This function is not yet implemented, check for #def ZZIP_NO_CREAT * Write-support will extend => zzip_closedir with semantics to finalize the * zip-archive by writing the zip-trailer and closing the archive file. */ ZZIP_DIR * zzip_dir_creat_ext_io(zzip_char_t * name, int o_mode, zzip_strings_t * ext, zzip_plugin_io_t io) { if (! io) io = zzip_get_default_io(); if (io != zzip_get_default_io()) { /* the current io-structure does not contain a "write" entry, * and therefore this parameter is useless. Anyone to expect * some behavior should be warned, so here we let the function * fail bluntly - and leaving the recovery to the application */ errno = EINVAL; return 0; } if (! _ZZIP_TRY) { /* not implemented - however, we respect that a null argument to * zzip_mkdir and zzip_creat works, so we silently still do the mkdir */ if (! _mkdir(name, o_mode) || errno == EEXIST) errno = EROFS; return 0; } else { # define MAX_EXT_LEN 10 ZZIP_DIR *dir = zzip_dir_alloc(ext); int name_len = strlen(name); dir->realname = malloc(name_len + MAX_EXT_LEN); if (! dir->realname) goto error; memcpy(dir->realname, name, name_len + 1); ___ int fd = __zzip_try_open(dir->realname, O_EXCL | O_TRUNC | O_WRONLY, ext, io); if (fd != -1) { dir->fd = fd; return dir; } ___ zzip_strings_t *exx = ext; int exx_len; for (; *exx; exx++) { if ((exx_len = strlen(*exx) + 1) <= name_len && ! memcmp(dir->realname + (name_len - exx_len), *exx, exx_len)) break; /* keep unmodified */ exx++; if (*exx) continue; if (! (exx_len = strlen(*exx)) || exx_len >= MAX_EXT_LEN) break; memcpy(dir->realname + name_len, exx, exx_len); /* append! */ } ____; fd = (io->fd.open)(dir->realname, O_CREAT | O_TRUNC | O_WRONLY, o_mode); dir->realname[name_len] = '\0'; /* keep ummodified */ if (fd != -1) { dir->fd = fd; return dir; } error: zzip_dir_free(dir); return 0; ____; } }