diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-07-17 11:49:10 +0200 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-07-17 11:49:10 +0200 |
| commit | 856c5d2837eac45567a4c83b22a5281f5d963d5c (patch) | |
| tree | 3716ffdce0bfa184f435c5664a118f8419171829 /main/main.c | |
| parent | 5a90dc77b8f244f603082aea022fadc0ce2c009c (diff) | |
| download | php-git-856c5d2837eac45567a4c83b22a5281f5d963d5c.tar.gz | |
Revert "Avoid unused fstat() call"
This reverts commit 5a90dc77b8f244f603082aea022fadc0ce2c009c.
Let's try to go with the reverse direction here and actually trust
the reported size...
Diffstat (limited to 'main/main.c')
| -rw-r--r-- | main/main.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/main/main.c b/main/main.c index bd713d3137..809ebbfd5e 100644 --- a/main/main.c +++ b/main/main.c @@ -1562,6 +1562,16 @@ static void php_zend_stream_closer(void *handle) /* {{{ */ } /* }}} */ +static size_t php_zend_stream_fsizer(void *handle) /* {{{ */ +{ + php_stream_statbuf ssb; + if (php_stream_stat((php_stream*)handle, &ssb) == 0) { + return ssb.sb.st_size; + } + return 0; +} +/* }}} */ + static int php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */ { return php_stream_open_for_zend_ex(filename, handle, USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE); @@ -1579,6 +1589,7 @@ PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *h handle->opened_path = opened_path; handle->handle.stream.handle = stream; handle->handle.stream.reader = (zend_stream_reader_t)_php_stream_read; + handle->handle.stream.fsizer = php_zend_stream_fsizer; handle->handle.stream.isatty = 0; handle->handle.stream.closer = php_zend_stream_closer; /* suppress warning if this stream is not explicitly closed */ |
