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


PHP Dir::exists方法代码示例

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


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

示例1: testRmdir

 function testRmdir()
 {
     $dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/module_plug_root/prova/");
     $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/"));
     $this->assertFalse($dir->exists(), "La directory c'e' gia'!!");
     $dir->touch();
     $this->assertTrue($dir->exists(), "La directory non e' stata creata!!");
     $plug->rmdir("prova");
     $this->assertFalse($dir->exists(), "La directory non e' stata eliminata!!");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:12,代码来源:dir_bridge_test.php

示例2: add

 function add()
 {
     if (Upload::isUploadSuccessful("my_file")) {
         $peer = new ImmaginiPeer();
         $do = $peer->new_do();
         $peer->setupByParams($do);
         $d = new Dir("/immagini/user/" . Session::get("/session/username") . Params::get("folder"));
         if (!$d->exists()) {
             $d->touch();
         }
         $do->save_folder = $d->getPath();
         $do->real_name = Upload::getRealFilename("my_file");
         $do->folder = Params::get("folder");
         $tokens = explode(".", Upload::getRealFilename("my_file"));
         $extension = $tokens[count($tokens) - 1];
         $do->hash_name = md5(uniqid()) . "." . strtolower($extension);
         Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
         $peer->save($do);
         if (is_html()) {
             Flash::ok("Immagine aggiunta con successo.");
             return Redirect::success();
         } else {
             return ActiveRecordUtils::toArray($do);
         }
     } else {
         Flash::error(Upload::getUploadError("my_file"));
         return Redirect::failure();
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:29,代码来源:ImmaginiController.class.php

示例3: 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

示例4: testCompressUncompress

 function testCompressUncompress()
 {
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa");
     $f->delete();
     FFArchive::compress($f, new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/data/"));
     $ext_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/");
     $ext_dir->touch();
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa");
     $this->assertTrue($f->exists(), "Il file da decomprimere non esiste!!");
     FFArchive::extract($f, $ext_dir);
     $f1 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/cartella.png");
     $this->assertTrue($f1->exists(), "Il file cartella.png non e' stato estratto!!");
     $this->assertEqual($f1->getSize(), 441, "La dimensione di cartella.png non corrisponde!!");
     $f2 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/file1.txt");
     $this->assertTrue($f2->exists(), "Il file file1.txt non e' stato estratto!!");
     $f3 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/file2.dat");
     $this->assertTrue($f3->exists(), "Il file file2.dat non e' stato estratto!!");
     $d1 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/empty_folder");
     $this->assertTrue($d1->exists(), "La cartella vuota non e' stata estratta!!");
     $d2 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/folder");
     $this->assertTrue($d2->exists(), "La cartella folder non e' stata estratta!!");
     $f4 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/folder/sub/yep.txt");
     $this->assertTrue($f4->exists(), "Il file yep.txt non e' stato estratto!!");
     $this->assertEqual($f4->getSize(), 10, "La dimensione di yep.txt non corrisponde!!");
     $this->assertTrue($ext_dir->delete(true), "La directory coi file estratti non e' stata elimintata!!");
     $this->assertFalse($f1->exists(), "Il file cartella.png esiste ancora!!");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:27,代码来源:ffarchive_test.php

示例5: create

 /**
  * Creates a directory
  *
  *  <code>
  *      Dir::create('folder1');
  *  </code>
  *
  * @param  string  $dir   Name of directory to create
  * @param  integer $chmod Chmod
  * @return boolean
  */
 public static function create($dir, $chmod = 0775)
 {
     // Redefine vars
     $dir = (string) $dir;
     // Create new dir if $dir !exists
     return !Dir::exists($dir) ? @mkdir($dir, $chmod, true) : true;
 }
开发者ID:Razzwan,项目名称:morfy,代码行数:18,代码来源:Dir.php

示例6: add

 function add()
 {
     ini_set('upload_max_filesize', 8388608 * 4);
     if (Upload::isUploadSuccessful("my_file")) {
         $peer = new DocumentiPeer();
         $do = $peer->new_do();
         $peer->setupByParams($do);
         $d = new Dir("/documenti/user/" . Session::get("/session/username") . "/contenuti/");
         if (!$d->exists()) {
             $d->touch();
         }
         $do->save_folder = $d->getPath();
         $do->real_name = Upload::getRealFilename("my_file");
         $do->folder = Params::get("folder");
         $tokens = explode(".", Upload::getRealFilename("my_file"));
         $extension = $tokens[count($tokens) - 1];
         $do->hash_name = md5(uniqid()) . "." . strtolower($extension);
         Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
         $peer->save($do);
         Flash::ok("Documento aggiunto con successo.");
         return Redirect::success();
     } else {
         return Redirect::failure(Upload::getUploadError("my_file"));
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:25,代码来源:DocumentiController.class.php

示例7: Dir

 static function set_modules_path($new_modules_path)
 {
     $dir = new Dir(DS . $new_modules_path);
     if (!$dir->exists()) {
         Log::error("ModuleUtils::set_modules_path", "Error : modules root directory must exist -> " . $new_modules_path);
     } else {
         self::$modules_path = $new_modules_path;
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:9,代码来源:ModuleUtils.class.php

示例8: RepositoryListException

 /**
  * 
  * @param string absolute path to config file
  */
 function __construct(Dir $path)
 {
     if (!$path->exists()) {
         throw new RepositoryListException('Given path(' . $path . ') not exists.');
     }
     $this->path = $path;
     $this->list = $path->getFile('list.txt');
     $this->createContext();
 }
开发者ID:point,项目名称:cassea,代码行数:13,代码来源:RepositoryList.php

示例9: Dir

 static function list_files($plugin_path)
 {
     $plugin_dir = new Dir(self::DEFAULT_DIR . $plugin_path);
     $final_result = array();
     if ($plugin_dir->exists()) {
         $all_files = $plugin_dir->findFilesEndingWith(self::DEFAULT_EXTENSION);
         foreach ($all_files as $f) {
             $final_result[] = $f->getIncludePath();
         }
     }
     return $final_result;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:12,代码来源:Plugin.class.php

示例10: rename

 function rename($new_name)
 {
     if (strstr($new_name, "/") !== false) {
         throw new InvalidParameterException("Il nome contiene caratteri non ammessi ( / )!!");
     }
     $parent_dir = $this->getParentDir();
     $target_path = $parent_dir->getPath() . "/" . $new_name;
     $target_dir = new Dir($target_path);
     if ($target_dir->exists()) {
         return false;
     }
     return rename($this->__full_path, $target_dir->getFullPath());
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:13,代码来源:Dir.class.php

示例11: Dir

 function __saveAttachedFile($do)
 {
     if ($this->__uploadMaxFilesize() != null) {
         ini_set('upload_max_filesize', $this->__uploadMaxFilesize());
     }
     $d = new Dir($this->__saveFolderPath());
     if (!$d->exists()) {
         $d->touch();
     }
     $do->save_folder = $d->getPath();
     $do->real_name = Upload::getRealFilename("my_file");
     $tokens = explode(".", Upload::getRealFilename("my_file"));
     $extension = $tokens[count($tokens) - 1];
     $do->hash_name = md5(uniqid()) . "." . strtolower($extension);
     Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:16,代码来源:AbstractKeyedFolderEntityController.class.php

示例12: testExtractFromArchive

 function testExtractFromArchive()
 {
     $result_file = new File(ModuleArchiver::MODULES_ARCHIVE_DIR . "test__category-1_2_3.ffa");
     $this->assertFalse($result_file->exists(), "Il file del modulo non e' stato creato!!");
     ModuleUtils::set_modules_path("/" . FRAMEWORK_CORE_PATH . "tests/modules/fakeroot2/modules/");
     ModuleArchiver::save_as_archive("test", "category");
     ModuleUtils::set_modules_path("/" . FRAMEWORK_CORE_PATH . "tests/modules/fakeroot2/modules_out/");
     ModuleArchiver::extract_from_archive("test__category-1_2_3.ffa");
     $extracted_module_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/modules/fakeroot2/modules_out/test/category/");
     $this->assertTrue($extracted_module_dir->exists(), "La cartella del modulo non e' stata creata!!");
     $module_file = $extracted_module_dir->newFile(AvailableModules::MODULE_DEFINITION_FILE);
     $this->assertTrue($module_file->exists(), "Il file di definizione del modulo non esiste!!");
     $parent_module_dir = $extracted_module_dir->getParentDir();
     $parent_module_dir->delete(true);
     ModuleUtils::set_modules_path("/framework/modules/");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:16,代码来源:module_archiver_test.php

示例13: pack

 /**
  *
  */
 static function pack(Dir $source, File $target)
 {
     if (!$source->exists()) {
         throw new PackerException('Source folder ' . $source . ' not readable.');
     }
     if (!$target->getParent()->canWrite()) {
         throw new PackerException('Target file ' . $target . ' not writable.');
     }
     $cmd = str_replace(array('{FILE}', '{TARGET}'), array($source, $target), self::$config['pack_template']);
     exec($cmd, $out, $res);
     if ($res) {
         $out[] = PHP_EOL . 'Exit code: ' . $res . PHP_EOL;
         $f = Dir::get(Config::getInstance()->root_dir, true)->getDir(self::$config['logDir'])->getFile('pack_' . basename($source) . '.log');
         file_put_contents($f, implode(PHP_EOL, $out));
         throw new PackerException('Error while unpacking. Return code: ' . $res . '. Log file stored at ' . $f);
     }
 }
开发者ID:point,项目名称:cassea,代码行数:20,代码来源:Packer.php

示例14: 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

示例15: factory

 /**
  * Template factory
  *
  *  <code>
  *      $template = Template::factory('templates_path');
  *  </code>
  *
  * @param string|Fenom\ProviderInterface $source path to templates or custom provider
  * @param string $compile_dir path to compiled files
  * @param int|array $options
  * @throws InvalidArgumentException
  * @return Fenom
  */
 public static function factory($source, $compile_dir = '/tmp', $options = 0)
 {
     // Create fenom cache directory if its not exists
     !Dir::exists(CACHE_PATH . '/fenom/') and Dir::create(CACHE_PATH . '/fenom/');
     // Create Unique Cache ID for Theme
     $theme_config_file = THEMES_PATH . '/' . Config::get('system.theme') . '/' . Config::get('system.theme') . '.yml';
     $theme_cache_id = md5('theme' . ROOT_DIR . $theme_config_file . filemtime($theme_config_file));
     // Set current them options
     if (Cache::driver()->contains($theme_cache_id)) {
         Config::set('theme', Cache::driver()->fetch($theme_cache_id));
     } else {
         $theme_config = Yaml::parseFile($theme_config_file);
         Config::set('theme', $theme_config);
         Cache::driver()->save($theme_cache_id, $theme_config);
     }
     $compile_dir = CACHE_PATH . '/fenom/';
     $options = Config::get('system.fenom');
     $fenom = parent::factory($source, $compile_dir, $options);
     $fenom->assign('config', Config::getConfig());
     return $fenom;
 }
开发者ID:xamedow,项目名称:bqs-site,代码行数:34,代码来源:Template.php


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