summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2023-10-12 15:19:36 +0200
committerRemi Collet <remi@php.net>2023-10-12 15:19:36 +0200
commit8bf3b94ac38682b4e5f1553ce0a501873dbcb855 (patch)
tree62facf14dac55546e421f85e0b8c565443a30345
parent16192a25a02e72eee26009f47bf85e0644ac3daf (diff)
implement fstat
-rw-r--r--rpminfo.c11
-rw-r--r--tests/014-stream.phpt4
2 files changed, 14 insertions, 1 deletions
diff --git a/rpminfo.c b/rpminfo.c
index 88868d5..16229d6 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -608,6 +608,15 @@ static int php_rpm_ops_close(php_stream *stream, int close_handle)
return EOF;
}
+static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb)
+{
+ STREAM_DATA_FROM_STREAM();
+
+ if (self) {
+ return rpmfiStat(self->fi, 0, &ssb->sb);
+ }
+ return -1;
+}
const php_stream_ops php_stream_rpmio_ops = {
NULL, /* write */
@@ -617,7 +626,7 @@ const php_stream_ops php_stream_rpmio_ops = {
"rpm",
NULL, /* seek */
NULL, /* cast */
- NULL, /* stat */
+ php_zip_ops_stat,
NULL /* set_option */
};
diff --git a/tests/014-stream.phpt b/tests/014-stream.phpt
index e8650f7..90192bf 100644
--- a/tests/014-stream.phpt
+++ b/tests/014-stream.phpt
@@ -12,6 +12,8 @@ $n = "rpm://" . __DIR__ . "/bidon.rpm#/usr/share/doc/bidon/README";
var_dump(in_array('rpm', stream_get_wrappers()));
var_dump($f = fopen($n, "r"));
+$s = fstat($f);
+var_dump($s['size'], $s['mode']);
var_dump(trim(fread($f, 10)));
var_dump(feof($f));
var_dump(trim(fread($f, 100)));
@@ -26,6 +28,8 @@ Done
--EXPECTF--
bool(true)
resource(%d) of type (stream)
+int(29)
+int(33188)
string(10) "Mon Feb 12"
bool(false)
string(17) "13:27:47 CET 2018"