stream_test.inc 931 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class SQLite3_Test_Stream
  3. {
  4. private $position;
  5. public static $string_length = 10;
  6. public static $string = "abcdefg\0hi";
  7. public function stream_open($path, $mode, $options, &$opened_path)
  8. {
  9. $this->position = 0;
  10. return true;
  11. }
  12. public function stream_read($count)
  13. {
  14. $ret = substr(self::$string, $this->position, $count);
  15. $this->position += strlen($ret);
  16. return $ret;
  17. }
  18. public function stream_write($data)
  19. {
  20. return 0;
  21. }
  22. public function stream_stat()
  23. {
  24. return array('size' => self::$string_length);
  25. }
  26. public function stream_tell()
  27. {
  28. return $this->position;
  29. }
  30. public function stream_eof()
  31. {
  32. return ($this->position >= self::$string_length);
  33. }
  34. }
  35. stream_wrapper_register('sqliteBlobTest', "SQLite3_Test_Stream") or die("Unable to register sqliteBlobTest stream");
  36. ?>