/**
  * Get the next entry from the directory handle.
  *
  * @param bool $ignorePeriodDirs [optional] True to ignore period directories such as /. and /.. .
  *
  * @return File|Directory|SymbolicLink|FilesystemObject|null The next filesystem object from the directory.
  */
 public function read($ignorePeriodDirs = true)
 {
     // Make sure a directory handle is opened
     if (!$this->isOpened()) {
         return null;
     }
     // Read the next entry from the directory handle, and make sure it's valid
     // TODO: Should we close the handle when null is returned?
     if (($entry = readdir($this->handle)) === false) {
         return null;
     }
     // Process single and double period entries
     if (($entry === '.' || $entry == '..') && $ignorePeriodDirs) {
         return $this->read($ignorePeriodDirs);
     }
     // Return period directories
     if ($entry === '.') {
         return $this->dir;
     } else {
         if ($entry === '..') {
             return $this->dir->getParent();
         }
     }
     // Create a proper filesystem object instance of the entry, return the result
     return FilesystemObject::from($this->dir, $entry);
 }
 /**
  * Get the target of the symbolic link.
  *
  * @param SymbolicLink|string $link Symbolic link instance or the symbolic link path as a string.
  * @param mixed|null $default [optional] The default value returned on failure.
  *
  * @return Directory|\carbon\core\io\filesystem\file\File|SymbolicLink|FilesystemObject|null
  * The target will be returned as Directory, File or SymbolicLink instance if the target exist.
  * If the target doesn't exist it will be returned as FileSystemObject instance instead.
  * The $default value will be returned on failure.
  */
 public static function getTarget($link, $default = null)
 {
     // Convert the link into a path string, return the $default value if failed
     if (($link = self::asPath($link, false)) === null) {
         return $default;
     }
     // Read the link, and make sure it's valid
     if (($path = readlink($link)) === false) {
         return $default;
     }
     // Return the result
     return FilesystemObject::from($path);
 }