diff options
author | Jakob Sack <kde@jakobsack.de> | 2011-07-29 21:03:53 +0200 |
---|---|---|
committer | Jakob Sack <kde@jakobsack.de> | 2011-07-29 21:03:53 +0200 |
commit | 2ff8d7a8bc067901ecbc64599b86d1b325f5fe98 (patch) | |
tree | 7523d0e4bde9a9c691112a71e2b0fe4c6904c078 /lib/fakedirstream.php | |
parent | 2bfad189e7e9c8ea78e4b5f78c9e779074dd991c (diff) | |
download | nextcloud-server-2ff8d7a8bc067901ecbc64599b86d1b325f5fe98.tar.gz nextcloud-server-2ff8d7a8bc067901ecbc64599b86d1b325f5fe98.zip |
One class per file!
Diffstat (limited to 'lib/fakedirstream.php')
-rw-r--r-- | lib/fakedirstream.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/fakedirstream.php b/lib/fakedirstream.php new file mode 100644 index 00000000000..fa3e64da62c --- /dev/null +++ b/lib/fakedirstream.php @@ -0,0 +1,45 @@ +<?php +global $FAKEDIRS; +$FAKEDIRS=array(); + +class fakeDirStream{ + private $name; + private $data; + private $index; + + public function dir_opendir($path,$options){ + global $FAKEDIRS; + $url=parse_url($path); + $this->name=substr($path,strlen('fakedir://')); + $this->index=0; + if(isset($FAKEDIRS[$this->name])){ + $this->data=$FAKEDIRS[$this->name]; + }else{ + $this->data=array(); + } + return true; + } + + public function dir_readdir(){ + if($this->index>=count($this->data)){ + return false; + } + $filename=$this->data[$this->index]; + $this->index++; + return $filename; + } + + public function dir_closedir() { + $this->data=false; + $this->name=''; + return true; + } + + public function dir_rewinddir() { + $this->index=0; + return true; + } +} + +stream_wrapper_register("fakedir", "fakeDirStream"); + |