dir.php 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace OC\Files\Stream;
  9. class Dir {
  10. private static $dirs = array();
  11. private $name;
  12. private $index;
  13. public function dir_opendir($path, $options) {
  14. $this->name = substr($path, strlen('fakedir://'));
  15. $this->index = 0;
  16. if (!isset(self::$dirs[$this->name])) {
  17. self::$dirs[$this->name] = array();
  18. }
  19. return true;
  20. }
  21. public function dir_readdir() {
  22. if ($this->index >= count(self::$dirs[$this->name])) {
  23. return false;
  24. }
  25. $filename = self::$dirs[$this->name][$this->index];
  26. $this->index++;
  27. return $filename;
  28. }
  29. public function dir_closedir() {
  30. $this->name = '';
  31. return true;
  32. }
  33. public function dir_rewinddir() {
  34. $this->index = 0;
  35. return true;
  36. }
  37. public static function register($path, $content) {
  38. self::$dirs[$path] = $content;
  39. }
  40. }