当前位置: 首页>>代码示例>>PHP>>正文


PHP Dir::listFiles方法代码示例

本文整理汇总了PHP中Dir::listFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Dir::listFiles方法的具体用法?PHP Dir::listFiles怎么用?PHP Dir::listFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dir的用法示例。


在下文中一共展示了Dir::listFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 function execute()
 {
     $file_or_folder = $this->file_or_folder;
     if (self::$dummy_mode) {
         echo "Adding : " . $file_or_folder . "<br />";
         return;
     }
     $root_dir_path = self::$root_dir->getPath();
     $file_or_folder = str_replace("\\", "/", $file_or_folder);
     $file_list = array();
     //se finisce con lo slash è una directory
     if (substr($file_or_folder, strlen($file_or_folder) - 1, 1) == "/") {
         //creo la cartella
         $target_dir = new Dir(DS . $root_dir_path . $file_or_folder);
         $target_dir->touch();
         $source_dir = new Dir($this->module_dir->getPath() . $file_or_folder);
         foreach ($source_dir->listFiles() as $elem) {
             if ($elem->isDir()) {
                 $file_list = array_merge($file_list, $this->add($file_or_folder . $elem->getName() . DS));
             } else {
                 $file_list = array_merge($file_list, $this->add($file_or_folder . $elem->getFilename()));
             }
         }
     } else {
         $source_file = new File($this->module_dir->getPath() . $file_or_folder);
         $target_file = new File($root_dir_path . $file_or_folder);
         $target_dir = $target_file->getDirectory();
         $target_dir->touch();
         $source_file->copy($target_dir);
         $file_list[] = $target_dir->newFile($source_file->getFilename())->getPath();
     }
     return $file_list;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:33,代码来源:AddModuleAction.class.php

示例2: 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;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:29,代码来源:FileUtils.class.php

示例3: testRemove

 function testRemove()
 {
     $module_plug_test_root = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/module_plug_root/");
     $target_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/module_plug_root/");
     $plug = new DirBridge($target_dir, new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/ecommerce/cart/"));
     $sub_dir = $module_plug_test_root->newSubdir("blocks");
     $block_file = $sub_dir->newFile("test.block.php");
     $block_file->setContent("BLA BLA BLA");
     $this->assertTrue($block_file->exists(), "Il file test.block.php non e' presente!!");
     $plug->remove("blocks/test.block.php");
     $this->assertFalse($block_file->exists(), "Il file test.block.php non e' stato rimosso!!");
     $js_dir = $module_plug_test_root->newSubdir("js");
     $js_dir->touch();
     $my_js_lib_subdir = $js_dir->newSubdir("my_js_lib");
     $my_js_lib_subdir->touch();
     $mylib_file = $my_js_lib_subdir->newFile("mylib.js");
     $mylib_file->setContent("HELLO!!");
     $this->assertTrue($mylib_file->exists(), "Il file non e' stato creato!!");
     $mylib3_file = $my_js_lib_subdir->newFile("mylib3.js");
     $mylib3_file->setContent("WORLD!!");
     $this->assertTrue($mylib3_file->exists(), "Il file non e' stato creato!!");
     $plug->remove("js/");
     $this->assertFalse($mylib_file->exists(), "Il file mylib.js non e' stato rimosso!!");
     $this->assertTrue($mylib3_file->exists(), "Il file mylib3.js e' stato rimosso!!");
     $all_module_plug_files = $module_plug_test_root->listFiles();
     foreach ($all_module_plug_files as $ff) {
         $ff->delete(true);
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:29,代码来源:dir_bridge_test.php

示例4: Dir

 static function get_available_module_archives()
 {
     $d = new Dir(self::MODULES_ARCHIVE_DIR);
     $d->touch();
     $d = new Dir(self::MODULES_ARCHIVE_DIR);
     $all_files = $d->listFiles();
     $result = array();
     foreach ($all_files as $ff) {
         $result[] = $ff->getName();
     }
     return $result;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:12,代码来源:ModuleArchiver.class.php

示例5: testExtractArchive

 function testExtractArchive()
 {
     $create_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/zip_test/create/");
     $this->assertTrue($create_dir->exists(), "La directory create non esiste!!");
     $save_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/zip_test/saved/");
     $this->assertTrue($save_dir->exists(), "La directory save non esiste!!");
     $extract_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/zip_test/extract/");
     $this->assertTrue($extract_dir->exists(), "La directory extract non esiste!!");
     $extract_dir_files = $extract_dir->listFiles();
     foreach ($extract_dir_files as $f) {
         $f->delete(true);
     }
     $target_file = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/zip_test/saved/test_archive.zip");
     $this->assertFalse($target_file->exists());
     $dir_to_zip = "/" . FRAMEWORK_CORE_PATH . "tests/io/zip_test/create/";
     ZipUtils::createArchive($target_file, $dir_to_zip);
     $this->assertTrue($target_file->exists(), "Il file zip non è stato creato!!");
     $this->assertTrue($target_file->getSize() > 0, "Il file creato ha dimensione vuota!!");
     //ora estraggo l'archivio
     $extract_root = "/" . FRAMEWORK_CORE_PATH . "tests/io/zip_test/extract/";
     ZipUtils::expandArchive($target_file, $extract_root);
     $this->assertEqual(count($extract_dir->listFiles()), 3, "Il numero dei file estratti non corrisponde!!");
     $f1 = new File($extract_root . "my_file_01.php");
     $this->assertTrue($f1->exists(), "Il file my_file_01.php non e' stato estratto!!");
     $this->assertTrue(!$f1->isEmpty(), "Il file my_file_01.php e' vuoto!!");
     $d1 = new Dir($extract_root . "another_dir/");
     $d2 = new Dir($extract_root . "my_subdir/");
     $f2 = new File($extract_root . "another_dir/blabla.ini");
     $this->assertTrue($f2->exists(), "Il file blabla.ini non e' stato estratto!!");
     $this->assertTrue(!$f2->isEmpty(), "Il file blabla.ini e' vuoto!!");
     $saved_files = $save_dir->listFiles();
     foreach ($saved_files as $f) {
         $f->delete(true);
     }
     $extracted_files = $extract_dir->listFiles();
     foreach ($extracted_files as $f) {
         $f->delete(true);
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:39,代码来源:zip_utils_test.php

示例6: unzipModule

 public static function unzipModule($fullPath, $remove = 'no')
 {
     if (!preg_match('/.*?\\.(zip|rar)/i', $fullPath)) {
         return false;
     }
     $zip = new Unzip($fullPath);
     $zip->extract();
     if ($remove != 'no') {
         unlink($fullPath);
     }
     $dirPath = dirname($fullPath) . '/';
     $listFiles = Dir::listFiles($dirPath);
     return $listFiles;
 }
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:14,代码来源:File.php

示例7: 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());
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:20,代码来源:CSS.class.php

示例8: array

 function get_rotator()
 {
     $result = array();
     $result["rotator_name"] = Params::get("name");
     $result["image_list"] = array();
     $d = new Dir(self::ROTATOR_GALLERIES_ROOT_PATH . $result["rotator_name"] . "/");
     if ($d->exists()) {
         $files = $d->listFiles();
         foreach ($files as $f) {
             if ($f->isFile()) {
                 $img = array();
                 $img["path"] = $f->getPath();
                 $img["title"] = str_replace("_", " ", $f->getName());
                 $result["image_list"][] = $img;
             }
         }
     } else {
         echo "Rotator gallery directory not found! : " . $d->getPath();
     }
     return $result;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:21,代码来源:RotatorController.class.php

示例9: array

 function get_gallery()
 {
     $gallery_name = Params::get("gallery_name");
     $result = array();
     $result["gallery_name"] = $gallery_name;
     $d = new Dir(self::GALLERY_ROOT_PATH . $gallery_name);
     $files = $d->listFiles();
     $image_list = array();
     foreach ($files as $f) {
         if ($f->isFile() && $f->getExtension() != ".ini") {
             $image = array();
             $image["path"] = $f->getPath();
             $image["title"] = str_replace("_", " ", $f->getName());
             $image_list[$f->getFilename()] = $image;
         }
     }
     $gallery_dir = new Dir(self::GALLERY_ROOT_PATH . $gallery_name . DS);
     $found_files = $gallery_dir->findFilesEndingWith("gallery.ini");
     if (count($found_files) > 0) {
         $gallery_ini_file = $found_files[0];
         $gallery_props = PropertiesUtils::readFromFile($gallery_ini_file, true);
         $enhanced_image_list = array();
         foreach ($section as $s) {
             $path = $s["path"];
             if (strpos($path, "DS") === 0) {
                 $new_image["path"] = $path;
             } else {
                 $new_image["path"] = self::GALLERY_ROOT_PATH . $gallery_name . $s["path"];
             }
             $f = new File($new_image["path"]);
             $new_image["title"] = isset($s["title"]) ? $s["title"] : str_replace("_", " ", $f->getName());
             $new_image["description"] = isset($s["description"]) ? $s["description"] : null;
             $enhanced_image_list[] = $new_image;
         }
         $result["image_list"] = $enhanced_image_list;
     } else {
         $result["image_list"] = $image_list;
     }
     return $result;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:40,代码来源:GalleryController.class.php

示例10: testAdd

 function testAdd()
 {
     $module_plug_test_root = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/modules/module_plug_root/");
     $module_plug_test_root->newSubdir("blocks")->touch();
     ModulePlug::setRootDir($module_plug_test_root->getPath());
     $plug = new ModulePlug(new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/ecommerce/cart/"));
     $plug->add("js/");
     $plug->add("blocks/test.block.php");
     $f_block = new File("/" . FRAMEWORK_CORE_PATH . "tests/modules/module_plug_root/blocks/test.block.php");
     $this->assertTrue($f_block->exists(), "Il file test.block.php non e' stato copiato!!");
     $f_no_plug = new File("/" . FRAMEWORK_CORE_PATH . "tests/modules/module_plug_root/blocks/no_plug.block.php");
     $this->assertFalse($f_no_plug->exists(), "Il file no_plug.block.php e' stato copiato!!");
     $f_jslib1 = new File("/" . FRAMEWORK_CORE_PATH . "tests/modules/module_plug_root/js/my_js_lib/mylib.js");
     $this->assertTrue($f_jslib1->exists(), "Il file libreria js1 non e' stato copiato!!");
     $f_jslib2 = new File("/" . FRAMEWORK_CORE_PATH . "tests/modules/module_plug_root/js/my_js_lib/mylib2.js");
     $this->assertTrue($f_jslib2->exists(), "Il file libreria js2 non e' stato copiato!!");
     ModulePlug::setRootDir("/");
     $all_module_plug_files = $module_plug_test_root->listFiles();
     foreach ($all_module_plug_files as $ff) {
         $ff->delete(true);
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:22,代码来源:module_plug_test.php

示例11: execute

 function execute()
 {
     $file_or_folder = $this->file_or_folder;
     $force = $this->force;
     if (self::$dummy_mode) {
         echo "Removing : " . $file_or_folder . "<br />";
         return;
     }
     $root_dir_path = self::$root_dir->getPath();
     //se è una cartella elimino solo i file che sono anche nel modulo
     if (FileSystemUtils::isDir($this->module_dir->getPath() . $file_or_folder)) {
         $source_dir = new Dir($this->module_dir->getPath() . $file_or_folder);
         $target_dir = new Dir($root_dir_path . $file_or_folder);
         if (!$target_dir->exists()) {
             return;
         }
         $toremove_files = $source_dir->listFiles();
         foreach ($toremove_files as $elem) {
             if ($elem->isDir()) {
                 $this->remove($file_or_folder . $elem->getName() . DS);
             } else {
                 $this->remove($file_or_folder . $elem->getFilename());
             }
         }
         if ($target_dir->isEmpty()) {
             $target_dir->delete(false);
         }
     } else {
         $source_file = new File($this->module_dir->getPath() . $file_or_folder);
         $target_file = new File($root_dir_path . $file_or_folder);
         if (!$force && !$source_file->exists()) {
             return;
         }
         //se non esiste nel modulo non lo rimuovo
         $target_file->delete();
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:37,代码来源:RemoveModuleAction.class.php

示例12: loadByLang

 public static function loadByLang($result, $lang, $dir, $recursive = false)
 {
     if ($dir instanceof Dir) {
         $props_dir = new Dir($dir);
     } else {
         $props_dir = new Dir($dir);
     }
     $all_files = $props_dir->listFiles();
     foreach ($all_files as $f) {
         if ($f->isDir() && $recursive) {
             $result = array_merge($result, self::loadByLang($result, $lang, $f, true));
         }
         if ($f->isFile()) {
             $full_extension = $f->getFullExtension();
             $ext_parts = explode(".", $full_extension);
             if (count($ext_parts) == 2 && $ext_parts[1] == "ini") {
                 $lang_part = $ext_parts[0];
                 if (substr($lang_part, 0, strlen($lang)) == $lang) {
                     $result = array_merge($result, PropertiesUtils::readFromFile($f, false));
                 }
             }
         }
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:24,代码来源:LangPropLoader.class.php

示例13: getAll

 static function getAll($folder)
 {
     $real_storage_dir = Storage::get_verified_storage();
     $result = array();
     $folder_dir = new Dir($real_storage_dir->getPath() . $folder . DS);
     if (!$folder_dir->exists()) {
         $real_storage_dir->newSubdir($folder);
     }
     $all_storages_files = $folder_dir->listFiles();
     foreach ($all_storages_files as $f) {
         if ($f->isFile()) {
             $result[] = Storage::byExtension($folder, $f->getName(), $f->getExtension());
         }
     }
     return $result;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:16,代码来源:Storage.class.php

示例14: testCreateStorageOnWrite

 function testCreateStorageOnWrite()
 {
     Storage::set_storage_root(DS . FRAMEWORK_CORE_PATH . "tests/io/storage_dir/");
     $d = new Dir(DS . FRAMEWORK_CORE_PATH . "tests/io/storage_dir/");
     foreach ($d->listFiles() as $f) {
         $f->delete(true);
     }
     $this->assertFalse($d->hasSingleSubdir(), "Lo storage e' gia' presente!!");
     $storage = Storage::getPropertiesStorage("boh", "ciccia");
     $this->assertFalse($storage->exists(), "Lo storage esiste gia'!!");
     $test_props = array("test" => "value", "hello" => "world");
     $storage->add("category", $test_props);
     $this->assertTrue($storage->exists(), "Lo storage non e' stato creato!!");
     $storage->delete();
     $this->assertFalse($storage->exists(), "Lo storage non e' stato eliminato!!");
     $properties = $storage->readAll();
     //readAll
     $this->assertTrue($storage->exists(), "Lo storage non e' stato creato per una lettura!!");
     $this->assertFalse($properties === null, "Il risultato ritornato e' ===null !!");
     $this->assertTrue(is_array($properties), "Il metodo non ha ritornato un array con uno storage inesistente!!");
     $this->assertTrue(count($properties) == 0, "L'array ritornato da una lettura di storage vuoto non e' vuoto!!");
     $storage->delete();
     $storage->remove("blah");
     //remove
     $this->assertTrue($storage->exists(), "Lo storage non e' stato creato per una cancellazione!!");
     $storage->delete();
     $storage->saveAll(array());
     //saveAll
     $this->assertTrue($storage->exists(), "Lo storage non e' stato creato per una cancellazione!!");
     $storage->delete();
     $this->assertFalse($storage->exists(), "Lo storage non e' stato eliminato!!");
     foreach ($d->listFiles() as $f) {
         $f->delete(true);
     }
     Storage::set_storage_root(Storage::get_default_storage_root());
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:36,代码来源:storage_test.php

示例15: array

 function get_gallery()
 {
     $gallery_name = Params::get("gallery_name");
     $result = array();
     $result["gallery_name"] = $gallery_name;
     $d = new Dir(self::GALLERY_ROOT_PATH . "/" . $gallery_name);
     $files = $d->listFiles();
     $image_list = array();
     foreach ($files as $f) {
         if ($f->isFile() && $f->getExtension() != "ini") {
             $image = array();
             $image["path"] = $f->getPath();
             $image["title"] = str_replace("_", " ", $f->getName());
             $image["name"] = $f->getFilename();
             $image["type"] = "image";
             $image_list[] = $image;
         }
     }
     $result["image_list"] = $image_list;
     return $result;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:21,代码来源:GalleryController.class.php


注:本文中的Dir::listFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。