Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function refresh()
 {
     // reset first
     $this->_directory = null;
     $this->_exists = false;
     $me = $this;
     $path = (string) $this->_fullName;
     if (@\is_link($path)) {
         $link = @\readlink($path);
         if (false !== $link) {
             $path = $link;
         }
     }
     // parent directory
     $this->_exists = \file_exists($path) && \is_file($path);
     // parent directory
     $this->_directory = new Lazy(function () use($me) {
         $result = null;
         $dirPath = \dirname((string) $me->fullName());
         if (!ClrString::isNullOrWhitespace($dirPath)) {
             $result = new DirectoryInfo($dirPath);
         }
         return $result;
     });
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function refresh()
 {
     // reset first
     $this->_directory = null;
     $this->_exists = false;
     $me = $this;
     $path = (string) $this->_fullName;
     if (@\is_link($path)) {
         $link = @\readlink($path);
         if (false !== $link) {
             $path = $link;
         }
     }
     // does exist?
     $this->_exists = \file_exists($path) && \is_dir($path);
     // parent directory
     $this->_directory = new Lazy(function () use($me) {
         $result = null;
         $np = $me->getType()->getMethod('normalizePath')->getClosure(null);
         $dirPath = $me->fullName()->asImmutable();
         if (!$dirPath->endsWith(\DIRECTORY_SEPARATOR)) {
             $dirPath = $dirPath->append(\DIRECTORY_SEPARATOR);
         }
         $dirPath = $dirPath->append('..');
         $dirPath = $np($dirPath);
         if (!ClrString::isNullOrWhitespace($dirPath)) {
             $result = $me->getType()->newInstance($dirPath);
         }
         return $result;
     });
 }