32struct php_zip_stream_data_t {
39#define STREAM_DATA_FROM_STREAM() \
40 struct php_zip_stream_data_t *self = (struct php_zip_stream_data_t *) stream->abstract;
47 STREAM_DATA_FROM_STREAM();
52#if LIBZIP_VERSION_MAJOR < 1
54 zip_file_error_get(self->zf, &ze, &se);
59 err = zip_file_get_error(self->zf);
68 if (
n == 0 ||
n < (ssize_t)
count) {
90static int php_zip_ops_close(
php_stream *stream,
int close_handle)
92 STREAM_DATA_FROM_STREAM();
111static int php_zip_ops_flush(
php_stream *stream)
133 fragment =
strchr(path,
'#');
143 fragment_len =
strlen(fragment);
145 if (fragment_len < 1) {
153 memcpy(file_dirname, path, path_len - fragment_len);
154 file_dirname[path_len - fragment_len] =
'\0';
156 file_basename =
php_basename((
char *)path, path_len - fragment_len,
NULL, 0);
167 if (zip_stat(za, fragment, ZIP_FL_NOCASE, &sb) != 0) {
174 if (path[path_len-1] !=
'/') {
175 ssb->
sb.st_size = sb.size;
176 ssb->
sb.st_mode |= S_IFREG;
179 ssb->
sb.st_mode |= S_IFDIR;
182 ssb->
sb.st_mtime = sb.mtime;
183 ssb->
sb.st_atime = sb.mtime;
184 ssb->
sb.st_ctime = sb.mtime;
185 ssb->
sb.st_nlink = 1;
186 ssb->
sb.st_rdev = -1;
188 ssb->
sb.st_blksize = -1;
189 ssb->
sb.st_blocks = -1;
198#if LIBZIP_ATLEAST(1,9,1)
203 STREAM_DATA_FROM_STREAM();
206 ret = zip_fseek(self->zf,
offset, whence);
207 *newoffset = zip_ftell(self->zf);
216 php_zip_ops_write, php_zip_ops_read,
217 php_zip_ops_close, php_zip_ops_flush,
228 php_zip_ops_write, php_zip_ops_read,
229 php_zip_ops_close, php_zip_ops_flush,
240 struct zip_file *zf =
NULL;
243 struct php_zip_stream_data_t *self;
250 zf = zip_fopen_index(arch, sb->index,
flags);
258#if LIBZIP_ATLEAST(1,9,1)
259 if (zip_file_is_seekable(zf) > 0) {
288 struct zip_file *zf =
NULL;
294 struct php_zip_stream_data_t *self;
296 fragment =
strchr(path,
'#');
305 fragment_len =
strlen(fragment);
307 if (fragment_len < 1) {
315 memcpy(file_dirname, path, path_len - fragment_len);
316 file_dirname[path_len - fragment_len] =
'\0';
336 zf = zip_fopen(za, fragment, 0);
344#if LIBZIP_ATLEAST(1,9,1)
345 if (zip_file_is_seekable(zf) > 0) {
354 *opened_path = zend_string_init(path,
strlen(path), 0);
count(Countable|array $value, int $mode=COUNT_NORMAL)
strchr(string $haystack, string $needle, bool $before_needle=false)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
PHP_JSON_API size_t int options
PHPAPI zval * php_stream_context_get_option(php_stream_context *context, const char *wrappername, const char *optionname)
struct _php_stream_wrapper_ops php_stream_wrapper_ops
struct _php_stream php_stream
struct _php_stream_context php_stream_context
struct _php_stream_ops php_stream_ops
struct _php_stream_wrapper php_stream_wrapper
#define php_stream_alloc(ops, thisptr, persistent_id, mode)
struct _php_stream_statbuf php_stream_statbuf
PHPAPI zend_string * php_basename(const char *s, size_t len, const char *suffix, size_t sufflen)
#define ZIP_OPENBASEDIR_CHECKPATH(filename)
php_stream * php_stream_zip_open(struct zip *arch, struct zip_stat *sb, const char *mode, zip_flags_t flags STREAMS_DC)
php_stream * php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC)
const php_stream_wrapper php_stream_zip_wrapper
zip_open(string $filename)
strncmp(string $string1, string $string2, int $length)
zend_string_release_ex(func->internal_function.function_name, 0)
#define strncasecmp(s1, s2, n)
struct _zend_string zend_string
#define Z_STRVAL_P(zval_p)