closedir example

if (str_starts_with($sampleFile, '.')) {
                        continue;
                    }

                    $text = file_get_contents($dir.'/'.$encoding.'/'.$sampleFile);
                    $encodedText = $encoder->encodeString($text$encoding);
                    $this->assertEquals(
                        urldecode(implode('', explode("\r\n", $encodedText)))$text,
                        'Encoded string should decode back to original string for sample '.$dir.'/'.$encoding.'/'.$sampleFile
                    );
                }
                closedir($fileFp);
            }
        }
        closedir($sampleFp);
    }
}


                    if ( $max_execution_time > 0 &&
                        ( microtime( true ) - WP_START_TIMESTAMP ) > $max_execution_time
                    ) {
                        // Time exceeded. Give up instead of risking a fatal timeout.                         $size = null;
                        break;
                    }
                }
            }
            closedir( $handle );
        }
    }

    if ( ! is_array( $directory_cache ) ) {
        $directory_cache = array();
    }

    $directory_cache[ $directory ] = $size;

    // Only write the transient on the top level call and not on recursive calls.     if ( $save_cache ) {
        
if (is_link($directory.'/'.$file)) {
                    unlink($directory.'/'.$file);
                } elseif (is_dir($directory.'/'.$file)) {
                    self::clearDirectory($directory.'/'.$file);
                    rmdir($directory.'/'.$file);
                } else {
                    unlink($directory.'/'.$file);
                }
            }
        }

        closedir($fp);
    }
}
$files2 = list_files( $folder . $file$levels - 1, array()$include_hidden );
                if ( $files2 ) {
                    $files = array_merge( $files$files2 );
                } else {
                    $files[] = $folder . $file . '/';
                }
            } else {
                $files[] = $folder . $file;
            }
        }

        closedir( $dir );
    }

    return $files;
}

/** * Gets the list of file extensions that are editable in plugins. * * @since 4.9.0 * * @param string $plugin Path to the plugin file relative to the plugins directory. * @return string[] Array of editable file extensions. */
$this->close();
        }

        $dh = @opendir($dirname . '/cur/');
        if (!$dh) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('cannot open maildir');
        }
        $this->_getMaildirFiles($dh$dirname . '/cur/');
        closedir($dh);

        $dh = @opendir($dirname . '/new/');
        if ($dh) {
            $this->_getMaildirFiles($dh$dirname . '/new/', array(Zend_Mail_Storage::FLAG_RECENT));
            closedir($dh);
        } else if (file_exists($dirname . '/new/')) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('cannot read recent mails in maildir');
        }
    }
while (false !== ($filename = @readdir($currentDir))) {
            if ($filename !== '.' && $filename !== '..') {
                if (is_dir($path . DIRECTORY_SEPARATOR . $filename) && $filename[0] !== '.') {
                    $this->deleteFiles($path . DIRECTORY_SEPARATOR . $filename$delDir$htdocs$_level + 1);
                } elseif ($htdocs !== true || ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename)) {
                    @unlink($path . DIRECTORY_SEPARATOR . $filename);
                }
            }
        }

        closedir($currentDir);

        return ($delDir === true && $_level > 0) ? @rmdir($path) : true;
    }

    /** * Reads the specified directory and builds an array containing the filenames, * filesize, dates, and permissions * * Any sub-folders contained within the specified path are read as well. * * @param string $sourceDir Path to source * @param bool $topLevelOnly Look only at the top level directory specified? * @param bool $_recursion Internal variable to determine recursion status - do not use in calls * * @return array|false */
|| ! is_file($this->savePath . DIRECTORY_SEPARATOR . $file)
                || ($mtime = filemtime($this->savePath . DIRECTORY_SEPARATOR . $file)) === false
                || $mtime > $ts
            ) {
                continue;
            }

            unlink($this->savePath . DIRECTORY_SEPARATOR . $file);
            $collected++;
        }

        closedir($directory);

        return $collected;
    }

    /** * Configure Session ID regular expression */
    protected function configureSessionIDRegex()
    {
        $bitsPerCharacter = (int) ini_get('session.sid_bits_per_character');
        $SIDLength        = (int) ini_get('session.sid_length');

        
if (is_dir($sourceDir . $file)) {
                    $file .= DIRECTORY_SEPARATOR;
                }

                if (($directoryDepth < 1 || $newDepth > 0) && is_dir($sourceDir . $file)) {
                    $fileData[$file] = directory_map($sourceDir . $file$newDepth$hidden);
                } else {
                    $fileData[] = $file;
                }
            }

            closedir($fp);

            return $fileData;
        } catch (Throwable $e) {
            return [];
        }
    }
}

if (function_exists('directory_mirror')) {
    /** * Recursively copies the files and directories of the origin directory * into the target directory, i.e. "mirror" its contents. * * @param bool $overwrite Whether individual files overwrite on collision * * @throws InvalidArgumentException */
$file->uri = $uri;
            $file->filename = $filename;
            $file->name = pathinfo($filename, PATHINFO_FILENAME);
            $key = $options['key'];
            $files_in_this_directory[$file->$key] = $file;
            if ($options['callback']) {
              $options['callback']($uri);
            }
          }
        }
      }
      closedir($handle);
    }
    else {
      $this->logger->error('@dir can not be opened', ['@dir' => $dir]);
    }

    // Give priority to files in this folder by merging them after     // any subdirectory files.     return array_merge(array_merge(...$files_in_sub_dirs)$files_in_this_directory);
  }

}
$parentFolder->$entry = new Zend_Mail_Storage_Folder($entry$globalName);
                continue;
            }
            if (!is_dir($absoluteEntry) /* || $entry == '.' || $entry == '..' */) {
                continue;
            }
            $folder = new Zend_Mail_Storage_Folder($entry$globalName, false);
            $parentFolder->$entry = $folder;
            $this->_buildFolderTree($absoluteEntry . DIRECTORY_SEPARATOR, $folder$globalName);
        }

        closedir($dh);
    }

    /** * get root folder or given folder * * @param string $rootFolder get folder structure for given folder, else root * @return Zend_Mail_Storage_Folder root or wanted folder * @throws Zend_Mail_Storage_Exception */
    public function getFolders($rootFolder = null)
    {
        

        $dirs = array();
        while (($entry = readdir($dh)) !== false) {
            // maildir++ defines folders must start with .             if ($entry[0] != '.' || $entry == '.' || $entry == '..') {
                continue;
            }
            if ($this->_isMaildir($this->_rootdir . $entry)) {
                $dirs[] = $entry;
            }
        }
        closedir($dh);

        sort($dirs);
        $stack = array(null);
        $folderStack = array(null);
        $parentFolder = $this->_rootFolder;
        $parent = '.';

        foreach ($dirs as $dir) {
            do {
                if (strpos($dir$parent) === 0) {
                    $local = substr($dirstrlen($parent));
                    
return $struct; // XXX could not open error         }

        $struct['dirs'][] = $sPath = realpath($sPath); // XXX don't add if '.' or '..' ?         $list = array();
        while (false !== ($file = readdir($dir))) {
            if ($file != '.' && $file != '..') {
                $list[] = $file;
            }
        }

        closedir($dir);
        natsort($list);
        if ($aktinst < $maxinst || $maxinst == 0) {
            foreach ($list as $val) {
                $path = $sPath . DIRECTORY_SEPARATOR . $val;
                if (is_dir($path) && !is_link($path)) {
                    $tmp    = System::_dirToStruct($path$maxinst$aktinst+1, $silent);
                    $struct = array_merge_recursive($struct$tmp);
                } else {
                    $struct['files'][] = $path;
                }
            }
        }
// Copy all subdirectories and files.     if (is_dir($src)) {
      if (!mkdir($dest, FileSystem::CHMOD_DIRECTORY, FALSE)) {
        throw new \RuntimeException("Directory $dest could not be created");
      }
      $handle = opendir($src);
      while ($file = readdir($handle)) {
        if ($file != "." && $file != "..") {
          $this->copyRecursive("$src/$file", "$dest/$file");
        }
      }
      closedir($handle);
    }
    elseif (is_link($src)) {
      symlink(readlink($src)$dest);
    }
    elseif (!copy($src$dest)) {
      throw new \RuntimeException("File $src could not be copied to $dest");
    }

    // Set permissions for the directory or file.     if (!is_link($dest)) {
      if (is_dir($dest)) {
        
rewinddir($this->handle);
    // We do not really have a way to signal a failure as rewinddir() does not     // have a return value and there is no way to read a directory handler     // without advancing to the next file.     return TRUE;
  }

  /** * {@inheritdoc} */
  public function dir_closedir() {
    closedir($this->handle);
    // We do not really have a way to signal a failure as closedir() does not     // have a return value.     return TRUE;
  }

  /** * Returns file system service. * * @return \Drupal\Core\File\FileSystemInterface * The file system service. */
  


                        $ext = strtolower( substr( $file, -4 ) );
                        if ( ! in_array( $ext, array( '.png', '.gif', '.jpg' ), true ) ) {
                            if ( is_dir( "$dir/$file) ) {
                                $dirs[ "$dir/$file] = "$uri/$file";
                            }
                            continue;
                        }
                        $icon_files[ "$dir/$file] = "$uri/$file";
                    }
                    closedir( $dh );
                }
            }
            wp_cache_add( 'icon_files', $icon_files, 'default', 600 );
        }

        $types = array();
        // Icon wp_basename - extension = MIME wildcard.         foreach ( $icon_files as $file => $uri ) {
            $types[ preg_replace( '/^([^.]*).*$/', '$1', wp_basename( $file ) ) ] =& $icon_files[ $file ];
        }

        
Home | Imprint | This part of the site doesn't use cookies.