本文整理汇总了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!!");
}
}
示例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');
}
示例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;
}
示例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!!");
}
示例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;
}
示例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);
}
}
示例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());
}
示例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();
}
示例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/");
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
示例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();
}
示例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();
}
}
示例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";
}