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


PHP Dir::newSubdir方法代码示例

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


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

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

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

示例3: extract

 static function extract($f, $dir)
 {
     if ($f instanceof File) {
         $source_file = $f;
     } else {
         $source_file = new File($f);
     }
     if ($dir instanceof Dir) {
         $target_dir = $dir;
     } else {
         $target_dir = new Dir($dir);
     }
     $reader = $source_file->openReader();
     $binarydata = $reader->read(3);
     $data = unpack("a3", $binarydata);
     if ($data[1] !== self::FF_ARCHIVE_HEADER) {
         throw new InvalidDataException("Intestazione del file non valida : " . $data[1]);
     }
     $binarydata = $reader->read(2 + 2 + 2);
     $data = unpack("v3", $binarydata);
     if ($data[1] !== self::CURRENT_MAJOR || $data[2] !== self::CURRENT_MINOR || $data[3] !== self::CURRENT_REV) {
         throw new InvalidDataException("Versione del file non supportata!! : " . $data[1] . "-" . $data[2] . "-" . $data[3]);
     }
     //properties
     $binarydata = $reader->read(2);
     $data = unpack("v", $binarydata);
     $properties_length = $data[1];
     if ($properties_length > 0) {
         $binarydata = $reader->read($properties_length);
         $data = unpack("a*", $binarydata);
         $properties = PropertiesUtils::readFromString($data[1], false);
     } else {
         $properties = array();
     }
     //num entries
     $binarydata = $reader->read(2);
     $data = unpack("v", $binarydata);
     $num_entries = $data[1];
     $i = 0;
     while ($i < $num_entries) {
         //entry type
         $binarydata = $reader->read(2);
         $data = unpack("v", $binarydata);
         $entry_type = $data[1];
         //path length
         $binarydata = $reader->read(2);
         $data = unpack("v", $binarydata);
         $path_length = $data[1];
         //path
         $binarydata = $reader->read($path_length);
         $data = unpack("a*", $binarydata);
         $path = $data[1];
         if ($entry_type === self::ENTRY_TYPE_DIR) {
             $d = $target_dir->newSubdir($path);
             $d->touch();
         }
         if ($entry_type === self::ENTRY_TYPE_FILE) {
             //compressed size
             $binarydata = $reader->read(4);
             $data = unpack("V", $binarydata);
             $num_bytes = $data[1];
             //compressed data
             $compressed_file_data = $reader->read($num_bytes);
             $uncompressed_file_data = gzuncompress($compressed_file_data);
             $f = new File($target_dir->getPath() . $path);
             $writer = $f->openWriter();
             $writer->write($uncompressed_file_data);
             $writer->close();
             //sha1 sum
             $sha1_checksum = $reader->read(20);
             if (strcmp($sha1_checksum, sha1_file($f->getFullPath(), true)) !== 0) {
                 throw new InvalidDataException("La somma sha1 non corrisponde per il file : " . $f->getPath());
             }
         }
         $i++;
     }
     $reader->close();
     return true;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:79,代码来源:FFArchive.class.php

示例4: testDeleteRecursive

 function testDeleteRecursive()
 {
     $d = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/delete_test_dir/");
     $this->assertTrue($d->exists(), "La cartella dal eliminare non esiste!!");
     $this->assertTrue($d->isEmpty(), "La cartella da popolare non e' vuota!!");
     $the_dir = $d->newSubdir("the_dir");
     $blabla = $the_dir->newFile("blabla.ini");
     $blabla->setContent("[section]\n\nchiave=valore\n\n");
     $hidden_test = $the_dir->newSubdir("hidden_test");
     $htaccess = $hidden_test->newFile(".htaccess");
     $htaccess->setContent("RewriteEngine on\n\n");
     $prova = $hidden_test->newFile("prova.txt");
     $prova->setContent("Questo e' un file con un testo di prova");
     $the_dir->delete(true);
     $this->assertFalse($the_dir->exists(), "La directory non e' stata eliminata!!");
     $this->assertTrue($d->isEmpty(), "Il contenuto della cartella non e' stato rimosso completamente!!");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:17,代码来源:plain_dir_test.php

示例5: copy

 function copy($path, $new_name = null)
 {
     if ($path instanceof Dir) {
         $target_dir = $path;
     } else {
         $target_dir = new Dir($path);
     }
     if ($target_dir instanceof Dir) {
         if ($new_name == null) {
             $new_name = $this->getName();
         }
         $copy_dir = $target_dir->newSubdir($new_name);
         $all_files = $this->listFiles();
         foreach ($all_files as $elem) {
             $elem->copy($copy_dir);
         }
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:18,代码来源:Dir.class.php


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