* @package php-vfs */ class FileSystem { protected $scheme; /** @var Container */ protected $container; /** * Class constructor. Will register both, the stream default options and wrapper handler. * * Note: Each FileSystem instance will create NEW stream wrapper/scheme. */ public function __construct() { $this->scheme = uniqid('phpvfs'); /* injecting components */ $this->container = $container = new Container(new Factory()); $this->container->root()->setScheme($this->scheme); $this->registerContextOptions($container); stream_wrapper_register($this->scheme, sprintf('\%s\%s', __NAMESPACE__, 'Wrapper')); } /** * Returns wrapper scheme. * * @return string */ public function scheme() { return $this->scheme; } /** * Registers Container object as default context option for scheme associated with FileSystem instance. * * @param Container $container */ protected function registerContextOptions(Container $container) { $defaultOptions = stream_context_get_options(stream_context_get_default()); stream_context_set_default(array_merge( $defaultOptions, array($this->scheme => array('Container' => $container)) )); } /** * Remoces wrapper registered for scheme associated with FileSystem instance. */ public function __destruct() { stream_wrapper_unregister($this->scheme); } /** * Returns Container instance. * * @return Container */ public function container() { return $this->container; } /** * Returns Root instance. * * @return Root */ public function root() { return $this->container()->root(); } /** * Returns absolute path to full URI path (with scheme) * * @param string $path - path without scheme * * @return string - path with scheme */ public function path($path) { $path = ltrim($path, '/'); return $this->scheme().'://'.$path; } /** * Creates and returns a directory * * @param string $path * @param bool $recursive * @param integer|null $mode * * @return Directory */ public function createDirectory($path, $recursive = false, $mode = null) { return $this->container()->createDir($path, $recursive, $mode); } /** * Creates and returns a file * * @param string $path * @param string|null $data * * @return File */ public function createFile($path, $data = null) { return $this->container()->createFile($path, $data); } /** * Creates fs structure * * @param array $structure */ public function createStructure(array $structure) { $this->container()->createStructure($structure); } /** * Creates and returns a link * * @param string $path * @param string $destinationPath * * @return Link */ public function createLink($path, $destinationPath) { return $this->container()->createLink($path, $destinationPath); } } __halt_compiler();----SIGNATURE:----gYERzV2+pbf1bl22SZOT7eX7j80LuGwOsg2yGVt82q0vgIb0X20bTpHlSigkY21UU0bCha8Q8rLoNRyEfBg0t6lOa7ewtK4Fyco28r1CdUNWrAWuEd5IHB95I2/9DaukjoptW33qhEQpPXrANXvdqhsrroLK8kkQCzFNAGLJkmryZfla7qlLjr6+/Y4CD/hnXYJ85CtdGQD9VGyHNinuWNUUeGaFejiejyuvV8ft9X46j15twLM2G3xADp8LUZZO7r+qurwcx5u5ooRBUmz7nqUweqzO33cj586dgjXMtVqDvFuBPJwR4wVDICwMILezVWqkod3I9nIAHtpvVPn8lhqVaFnlUEXa2ZL0Z4ykmvZEuGqDYNfRnG3Yg84LTE7Iv0Vq05ZNHEN23CMJjTJzezoVoBjGwl+EnYhVF3Za+Yw4FYSR8nxdVuZK1qNJvHlc34KJ8KEfOWv4rbpe5AhuadnFDyCs8ICQep7XzKR98ZJHEDkB6Tm6bg6Mt4/yBJgyxqdFt3R/NwqnfFlO3jewKfgICotpcByezqa5bm0bYyGCyzwZ+zI/wWrCZp6rvW15ME6lUMHWSe5y68iQRmg9akVUjzVhY/3Hs91sIhEYiWB8HnaMrWAF1UY0Up582QJOdq0OQMoWnKHqfdhLHhiPUX0rzuZRcZgPMQDv7J9qH0o=----ATTACHMENT:----Nzg4OTc3NzkwNjE3OTM5NyAzNzM1MjY2NDQ1NDcyMTIyIDQ1MTY3NjM2NjI5NDMzNDQ=