mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-27 04:24:45 +01:00
a25595f43a
This change modifies the uv_fs_read() function signature slightly by adding a new $offset parameter. This allows the same file handle to be reused for multiple reads. Previously the only way to access a section of a file that had already been read was to open a new handle. Old: uv_fs_read(resoruce $loop, zval $fd, long $length, callable $callback) New: uv_fs_read(resoruce $loop, zval $fd, long $offest, long $length, callable $callback) This change represents a minor BC break for existing code using uv_fs_read().
24 lines
579 B
PHP
24 lines
579 B
PHP
--TEST--
|
|
Check for fs read and close
|
|
--FILE--
|
|
<?php
|
|
define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/hello.data");
|
|
|
|
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) {
|
|
if ($nread <= 0) {
|
|
if ($nread < 0) {
|
|
throw new Exception("read error");
|
|
}
|
|
|
|
uv_fs_close(uv_default_loop(), $stream, function(){
|
|
});
|
|
} else {
|
|
echo $data;
|
|
}
|
|
});
|
|
});
|
|
|
|
uv_run();
|
|
--EXPECT--
|
|
Hello |