本文整理汇总了PHP中XLite\Core\Converter::formatFileSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::formatFileSize方法的具体用法?PHP Converter::formatFileSize怎么用?PHP Converter::formatFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite\Core\Converter
的用法示例。
在下文中一共展示了Converter::formatFileSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doNoAction
/**
* Preprocessor for no-action
*
* @return void
*/
protected function doNoAction()
{
$this->startTime = time();
$this->startMemory = memory_get_usage(true);
$this->memoryLimitIni = \XLite\Core\Converter::convertShortSize(ini_get('memory_limit') ?: '16M');
foreach (\XLite\Core\Database::getRepo('XLite\\Model\\Task')->getCurrentQuery() as $task) {
$task = $task[0];
$runner = $task->getOwnerInstance();
if ($runner) {
$this->runRunner($runner);
}
sleep($this->sleepTime);
if (!$this->checkThreadResource()) {
$time = gmdate('H:i:s', time() - $this->startTime);
$memory = \XLite\Core\Converter::formatFileSize(memory_get_usage(true));
$this->printContent('Step is interrupted (time: ' . $time . '; memory usage: ' . $memory . ')');
break;
}
}
}
示例2: formatFileSize
/**
* Prepare human-readable output for file size
*
* @param integer $size Size in bytes
*
* @return string
*/
protected function formatFileSize($size)
{
return \XLite\Core\Converter::formatFileSize($size);
}
示例3: checkDiskFreeSpace
/**
* Check if there is enough disk free space.
* Return message on error
*
* @return string
*/
protected function checkDiskFreeSpace()
{
$message = null;
$totalSize = \Includes\Utils\ArrayManager::sumObjectsArrayFieldValues($this->getEntries(), 'getPackSize');
$freeSpaceRaw = \Includes\Utils\FileManager::getDiskFreeSpace(LC_DIR_TMP);
$freeSpace = null !== $freeSpaceRaw ? max(0, $freeSpaceRaw - self::FREE_SPACE_RESERVE) : null;
if (null !== $freeSpace && $totalSize > $freeSpace) {
$message = \XLite\Core\Translation::getInstance()->translate('Not enough disk space. Required: {{req}} (+{{reserve}} reserve). Available: {{avail}}', array('req' => \XLite\Core\Converter::formatFileSize($totalSize), 'reserve' => \XLite\Core\Converter::formatFileSize(self::FREE_SPACE_RESERVE), 'avail' => \XLite\Core\Converter::formatFileSize($freeSpace)));
}
return $message;
}