X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fmikey179%2FvfsStream%2Fsrc%2Fmain%2Fphp%2Forg%2Fbovigo%2Fvfs%2Fvisitor%2FvfsStreamPrintVisitor.php;fp=vendor%2Fmikey179%2FvfsStream%2Fsrc%2Fmain%2Fphp%2Forg%2Fbovigo%2Fvfs%2Fvisitor%2FvfsStreamPrintVisitor.php;h=15b0bc0c5495085f18a5d935b7a461772737ebf7;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitor.php b/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitor.php new file mode 100644 index 000000000..15b0bc0c5 --- /dev/null +++ b/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitor.php @@ -0,0 +1,107 @@ +out = $out; + } + + /** + * visit a file and process it + * + * @param vfsStreamFile $file + * @return vfsStreamPrintVisitor + */ + public function visitFile(vfsStreamFile $file) + { + $this->printContent($file->getName()); + return $this; + } + + /** + * visit a block device and process it + * + * @param vfsStreamBlock $block + * @return vfsStreamPrintVisitor + */ + public function visitBlockDevice(vfsStreamBlock $block) + { + $name = '[' . $block->getName() . ']'; + $this->printContent($name); + return $this; + } + + /** + * visit a directory and process it + * + * @param vfsStreamDirectory $dir + * @return vfsStreamPrintVisitor + */ + public function visitDirectory(vfsStreamDirectory $dir) + { + $this->printContent($dir->getName()); + $this->depth++; + foreach ($dir as $child) { + $this->visit($child); + } + + $this->depth--; + return $this; + } + + /** + * helper method to print the content + * + * @param string $name + */ + protected function printContent($name) + { + fwrite($this->out, str_repeat(' ', $this->depth) . '- ' . $name . "\n"); + } +}