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


PHP File::getSize方法代码示例

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


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

示例1: testWriterOpenButDontChange

 function testWriterOpenButDontChange()
 {
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/reader_writer/myfile_01.txt");
     $this->assertEqual(24, $f->getSize(), "La dimensione del file non corrisponde!! : " . $f->getSize());
     try {
         $writer = $f->openWriter();
         $this->assertTrue($writer instanceof FileWriter, "L'oggetto non e' del tipo specificato!!");
         $this->assertTrue($writer->isOpen(), "Il writer non e' aperto!!");
         $writer->close();
         $this->assertFalse($writer->isOpen(), "Il writer non e' stato chiuso!!");
     } catch (Exception $ex) {
         $this->fail("Errore nell'apertura del writer di un file esistente!!");
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:14,代码来源:file_writer_test.php

示例2: testGetSize

 /**
  * Tests File::getSize
  */
 public function testGetSize()
 {
     $spl = $this->getFileInfo();
     $file = new File($spl);
     $size = $file->getSize();
     $this->assertEquals($spl->getSize(), $size, 'size should match');
 }
开发者ID:todiadiyatmo,项目名称:phpbu,代码行数:10,代码来源:FileTest.php

示例3: getDuplicates

 /**
  * @return array|null
  */
 public function getDuplicates()
 {
     $this->loadFile();
     if (!is_null($this->mDupes)) {
         return $this->mDupes;
     }
     $hash = $this->mFile->getSha1();
     if (!$hash) {
         $this->mDupes = [];
         return $this->mDupes;
     }
     $dupes = RepoGroup::singleton()->findBySha1($hash);
     // Remove duplicates with self and non matching file sizes
     $self = $this->mFile->getRepoName() . ':' . $this->mFile->getName();
     $size = $this->mFile->getSize();
     /**
      * @var $file File
      */
     foreach ($dupes as $index => $file) {
         $key = $file->getRepoName() . ':' . $file->getName();
         if ($key == $self) {
             unset($dupes[$index]);
         }
         if ($file->getSize() != $size) {
             unset($dupes[$index]);
         }
     }
     $this->mDupes = $dupes;
     return $this->mDupes;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:33,代码来源:WikiFilePage.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: index

 public function index()
 {
     $file = $this->fetchParam("file", null, null, null, false);
     $fileSize = File::getSize(BASE_PATH . $file);
     $file_info = array("file_ext" => File::getExtension(BASE_PATH . $file), "file_size" => $fileSize, "file_size_kilobytes" => number_format($fileSize / 1024), "file_size_human" => self::format_bytes_human($fileSize));
     return $file_info;
 }
开发者ID:Synergy23,项目名称:RealEstate,代码行数:7,代码来源:pi.fileinfo.php

示例6: index

 public function index($file, $parameters = array())
 {
     $file = Path::assemble(BASE_PATH, $file);
     if (File::exists($file)) {
         $fileSize = File::getSize(BASE_PATH . $file);
         switch ($parameters) {
             case "file_ext":
                 return File::getExtension($file);
                 break;
             case "file_size":
                 return File::getSize(BASE_PATH . $file);
                 break;
             case "file_size_kilobytes":
                 return number_format($fileSize / 1024);
                 break;
             case "file_size_human":
                 return self::format_bytes_human($fileSize);
                 break;
             default:
                 return File::getExtension($file);
         }
     } else {
         Log::error("File does not exist or is not readable", "fileinfo_modifier", $file);
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:25,代码来源:mod.fileinfo.php

示例7: testGetSize

 function testGetSize()
 {
     $f_test_file = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/test_file.txt");
     $f_ext_test = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/ext_test.plug.txt");
     $this->assertEqual(12, $f_test_file->getSize());
     $this->assertEqual(0, $f_ext_test->getSize());
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:7,代码来源:plain_file_test.php

示例8: testBackupDir

 function testBackupDir()
 {
     $resulting_path = Backup::backup_dir("/" . FRAMEWORK_CORE_PATH . "tests/io/advances_dir_list/");
     $f = new File($resulting_path);
     $this->assertTrue($f->exists(), "Il file di backup non e' stato creato!!");
     $this->assertTrue($f->getSize() > 0, "Il file ha dimensione nulla!!");
     $f->delete();
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:8,代码来源:backup_test.php

示例9: testSaveAsArchive

 function testSaveAsArchive()
 {
     $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/");
     $this->assertTrue(AvailableModules::is_module_available("test", "category"), "Il modulo test/category non e' disponibile!!");
     ModuleArchiver::save_as_archive("test", "category");
     $this->assertTrue($result_file->exists(), "Il file del modulo non e' stato creato!!");
     $this->assertTrue($result_file->getSize() > 0, "Il file e' vuoto!!");
     $result_file->delete();
     ModuleUtils::set_modules_path("/framework/modules/");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:12,代码来源:module_archiver_test.php

示例10: get_layout_cache_key

 private function get_layout_cache_key()
 {
     if ($this->layout_cache_key != null) {
         return $this->layout_cache_key;
     }
     $layout_class_source = ClassLoader::instance()->get_element_content_by_name(get_class($this));
     $f = new File("/" . $this->layout_path);
     $layout_file_path = $f->getPath();
     $layout_file_size = $f->getSize();
     $layout_modification_time = $f->getModificationTime();
     $this->layout_cache_key = md5($layout_class_source . $layout_file_path . $layout_file_size . $layout_modification_time);
     return $this->layout_cache_key;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:13,代码来源:Layout.class.php

示例11: write

 /**
  * Writes a line in the log file
  *
  * @param string $line
  */
 public function write($line)
 {
     File::append($this->filepath, date($this->date_format) . ' - ' . $line . "\n");
     // If the max size is exceeded
     if (File::getSize($this->filepath) >= $this->max_size) {
         File::delete($this->filepath . '.' . $this->nb_old_logs);
         for ($i = $this->nb_old_logs; $i >= 1; $i--) {
             if (File::exists($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)))) {
                 File::rename($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)), $this->filepath . '.' . $i);
             }
         }
     }
 }
开发者ID:Godefroy,项目名称:confeature,代码行数:18,代码来源:class.Log.php

示例12: redactor__fetch_files

 public function redactor__fetch_files()
 {
     $this->authCheck();
     $dir = Path::tidy(ltrim(Request::get('path'), '/') . '/');
     $file_list = glob($dir . "*.*", GLOB_BRACE);
     $files = array();
     if (count($file_list) > 0) {
         foreach ($file_list as $file) {
             $pi = pathinfo($file);
             $files[] = array('link' => Path::toAsset($file), 'title' => $pi['filename'], 'name' => $pi['basename'], 'size' => File::getHumanSize(File::getSize(Path::assemble(BASE_PATH, $file))));
         }
     }
     echo json_encode($files);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:14,代码来源:hooks.redactor.php

示例13: control

 public function control()
 {
     $this->redirectToSternIndiaEndPoint();
     $config = Config::getInstance();
     if (isset($_POST['upload']) && $_POST['upload'] == 'Upload') {
         $target_dir = new FileSystem('upload/');
         $file = new File('foo', $target_dir);
         $name = date('D_d_m_Y_H_m_s_');
         $name = $name . $file->getName();
         $file->setName($name);
         $config = Config::getInstance();
         $file->addValidations(array(new Mimetype($config->getMimeTypes()), new Size('5M')));
         $data = array('name' => $file->getNameWithExtension(), 'extension' => $file->getExtension(), 'mime' => $file->getMimetype(), 'size' => $file->getSize(), 'md5' => $file->getMd5());
         try {
             // /Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__,$data);
             $file->upload();
             //Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__,$data);
         } catch (Exception $e) {
             $errors = $file->getErrors();
         }
         $csvReader = new CSVReader();
         $destinationFile = $target_dir->directory . $file->getNameWithExtension();
         $data = $csvReader->parse_file($destinationFile);
         //$country= DAOFactory::getDAO('LocationDAO');
         foreach ($data as $loc_arr) {
             Utils::processLocation($loc_arr);
         }
         //Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__);
         $target_dir = "uploads/";
         $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
         $uploadOk = 1;
         $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
         // Check if image file is a actual image or fake image
         if (isset($_POST["submit"])) {
             $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
             if ($check !== false) {
                 echo "File is an image - " . $check["mime"] . ".";
                 $uploadOk = 1;
             } else {
                 echo "File is not an image.";
                 $uploadOk = 0;
             }
         }
     }
     return $this->generateView();
 }
开发者ID:prabhatse,项目名称:olx_hack,代码行数:46,代码来源:class.FileUploadController.php

示例14: index

 public function index($file, $parameters = array())
 {
     switch ($parameters) {
         case "file_ext":
             return File::getExtension();
             break;
         case "file_size":
             return File::getSize(BASE_PATH . $file);
             break;
         case "file_size_kilobytes":
             return number_format($fileSize / 1024);
             break;
         case "file_size_human":
             return self::format_bytes_human($fileSize);
             break;
         default:
             return File::getExtension();
     }
 }
开发者ID:Synergy23,项目名称:RealEstate,代码行数:19,代码来源:mod.fileinfo.php

示例15: writeUpload

 /**
  * @param File $file
  * @param bool $dumpContents
  * @return string
  */
 function writeUpload($file, $dumpContents = false)
 {
     if ($file->isOld()) {
         $archiveName = "      " . Xml::element('archivename', null, $file->getArchiveName()) . "\n";
     } else {
         $archiveName = '';
     }
     if ($dumpContents) {
         $be = $file->getRepo()->getBackend();
         # Dump file as base64
         # Uses only XML-safe characters, so does not need escaping
         # @todo Too bad this loads the contents into memory (script might swap)
         $contents = '      <contents encoding="base64">' . chunk_split(base64_encode($be->getFileContents(array('src' => $file->getPath())))) . "      </contents>\n";
     } else {
         $contents = '';
     }
     if ($file->isDeleted(File::DELETED_COMMENT)) {
         $comment = Xml::element('comment', array('deleted' => 'deleted'));
     } else {
         $comment = Xml::elementClean('comment', null, $file->getDescription());
     }
     return "    <upload>\n" . $this->writeTimestamp($file->getTimestamp()) . $this->writeContributor($file->getUser('id'), $file->getUser('text')) . "      " . $comment . "\n" . "      " . Xml::element('filename', null, $file->getName()) . "\n" . $archiveName . "      " . Xml::element('src', null, $file->getCanonicalURL()) . "\n" . "      " . Xml::element('size', null, $file->getSize()) . "\n" . "      " . Xml::element('sha1base36', null, $file->getSha1()) . "\n" . "      " . Xml::element('rel', null, $file->getRel()) . "\n" . $contents . "    </upload>\n";
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:28,代码来源:Export.php


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