本文整理汇总了PHP中Dir::isDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Dir::isDir方法的具体用法?PHP Dir::isDir怎么用?PHP Dir::isDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dir
的用法示例。
在下文中一共展示了Dir::isDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: randomFromFolder
static function randomFromFolder($path, $autocache = true, $include_sub_dirs = false)
{
$dir = new Dir($path);
if (!$dir->exists()) {
Log::error("FileUtils::randomFromFolder", "La cartella {$path} non esiste!!");
}
if (!$dir->isDir()) {
Log::error("FileUtils::randomFromFolder", "Il percorso {$path} non rappresenta una cartella!!");
}
$results = $dir->listFiles();
$valid_results = array();
foreach ($results as $dir_elem) {
if ($dir_elem->isDir() && $include_sub_dirs) {
$valid_results[] = $dir_elem;
}
if ($dir_elem->isFile()) {
$valid_results[] = $dir_elem;
}
}
if (count($valid_results) == 0) {
Log::error("FileUtils::randomFromFolder", "Non sono stati trovati risultati validi!!");
}
$selected = $valid_results[rand(0, count($valid_results) - 1)];
$final_result = $selected->getPath();
if ($autocache) {
$final_result .= "?mtime=" . $selected->getModificationTime();
}
return $final_result;
}
示例2: array
static function get_all_available_by_category($nome_categoria)
{
$result = array();
$category_root = new Dir(DS . ModuleUtils::get_modules_path() . DS . $nome_categoria . DS);
if ($category_root->exists() && $category_root->isDir()) {
$all_folders = $category_root->listFolders();
foreach ($all_folders as $mod) {
//aggiunto controllo su esistenza modulo definizione
$mod_def = new File($mod->getPath() . self::MODULE_DEFINITION_FILE);
if ($mod_def->exists()) {
$result[] = $mod->getName();
}
}
}
if ($nome_categoria == ModuleUtils::FRAMEWORK_CATEGORY_NAME) {
$result[] = ModuleUtils::FRAMEWORK_MODULE_NAME;
}
return $result;
}
示例3: load_from_dir
public static function load_from_dir($dir)
{
if ($dir instanceof Dir) {
$my_dir = $dir;
} else {
$my_dir = new Dir($dir);
}
self::$css_dirs[] = $my_dir;
//CSS_DIRS
if ($my_dir->exists() && $my_dir->isDir()) {
$file_list = $my_dir->listFiles();
foreach ($file_list as $f) {
if ($f->isFile() && $f->getExtension() == "css") {
self::require_css_file($f);
}
}
} else {
Log::warn("load_from_dir", "Impossibile caricare i css dalla directory : " . $my_dir->getName());
}
}
示例4: testDirectoryContent
function testDirectoryContent()
{
$d1 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/");
$this->assertTrue($d1->isDir());
$content = $d1->listFiles();
$this->assertEqual(3, count($content));
//.svn ???
foreach ($content as $dir) {
if ($dir->getName() == "content_dir") {
$this->verifyContentDir($dir);
} else {
$this->verifyEmptyDir($dir);
}
}
}