2013-01-28 14:34:15 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-02-26 10:37:37 +00:00
|
|
|
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
2013-01-28 14:34:15 +00:00
|
|
|
*/
|
2015-02-26 10:37:37 +00:00
|
|
|
|
2013-01-28 14:34:15 +00:00
|
|
|
namespace OC\Files\Stream;
|
|
|
|
|
|
|
|
class Dir {
|
|
|
|
private static $dirs = array();
|
|
|
|
private $name;
|
|
|
|
private $index;
|
|
|
|
|
|
|
|
public function dir_opendir($path, $options) {
|
|
|
|
$this->name = substr($path, strlen('fakedir://'));
|
|
|
|
$this->index = 0;
|
|
|
|
if (!isset(self::$dirs[$this->name])) {
|
|
|
|
self::$dirs[$this->name] = array();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dir_readdir() {
|
|
|
|
if ($this->index >= count(self::$dirs[$this->name])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$filename = self::$dirs[$this->name][$this->index];
|
|
|
|
$this->index++;
|
|
|
|
return $filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dir_closedir() {
|
|
|
|
$this->name = '';
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dir_rewinddir() {
|
|
|
|
$this->index = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-06 15:30:58 +00:00
|
|
|
/**
|
|
|
|
* @param string $path
|
|
|
|
*/
|
2013-01-28 14:34:15 +00:00
|
|
|
public static function register($path, $content) {
|
|
|
|
self::$dirs[$path] = $content;
|
|
|
|
}
|
|
|
|
}
|