2012-07-03 01:20:50 +02:00
|
|
|
--TEST--
|
2013-02-11 14:09:29 +01:00
|
|
|
Check for fs read and close
|
2012-07-03 01:20:50 +02:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/hello.data");
|
|
|
|
|
2015-01-18 02:58:40 +01:00
|
|
|
uv_fs_open(uv_default_loop(), FIXTURE_PATH, UV::O_RDONLY, 0, function($r) {
|
|
|
|
uv_fs_read(uv_default_loop(), $r, $offset = 0, $len = 32, function($stream, $nread, $data) {
|
2014-11-23 19:02:03 +01:00
|
|
|
if ($nread <= 0) {
|
|
|
|
if ($nread < 0) {
|
|
|
|
throw new Exception("read error");
|
|
|
|
}
|
|
|
|
|
2015-01-18 02:58:40 +01:00
|
|
|
uv_fs_close(uv_default_loop(), $stream, function() { });
|
2014-11-23 19:02:03 +01:00
|
|
|
} else {
|
2015-01-18 17:24:13 +01:00
|
|
|
echo trim($data) . "\n";
|
2014-11-23 19:02:03 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// test offset
|
2015-01-18 02:58:40 +01:00
|
|
|
uv_fs_open(uv_default_loop(), FIXTURE_PATH, UV::O_RDONLY, 0, function($r) {
|
|
|
|
uv_fs_read(uv_default_loop(), $r, $offset = 1, $len = 32, function($stream, $nread, $data) {
|
2012-07-03 01:20:50 +02:00
|
|
|
if ($nread <= 0) {
|
|
|
|
if ($nread < 0) {
|
|
|
|
throw new Exception("read error");
|
|
|
|
}
|
|
|
|
|
2015-01-18 02:58:40 +01:00
|
|
|
uv_fs_close(uv_default_loop(), $stream, function() { });
|
2012-07-03 01:20:50 +02:00
|
|
|
} else {
|
2015-01-18 17:24:13 +01:00
|
|
|
echo "H" . trim($data) . "\n";
|
2012-07-03 01:20:50 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-11-23 19:02:03 +01:00
|
|
|
|
2012-07-03 01:20:50 +02:00
|
|
|
uv_run();
|
2015-01-18 17:24:13 +01:00
|
|
|
?>
|
2012-07-03 01:20:50 +02:00
|
|
|
--EXPECT--
|
2014-11-23 19:02:03 +01:00
|
|
|
Hello
|
2015-01-18 17:24:13 +01:00
|
|
|
Hello
|