Get a human file size.

@param string $file The file path

@return string The human size
12862
public function humanFileSize($file)
    {
        $size = filesize($file);
        $mod = 1024;
        $units = explode(' ', 'B KB MB GB TB PB');
        for ($i = 0; $size > $mod; ++$i) {
            $size /= $mod;
        }

        return round($size, 2).' '.$units[$i];
    }
164346
public function size()
    {
        $position = ftell($this->_fileHandle);
        fseek($this->_fileHandle, 0, SEEK_END);
        $size = ftell($this->_fileHandle);
        fseek($this->_fileHandle, $position);

        return $size;
    }
1023108
public static function dirsize(string $path) {
		$size = 0;
		$files = static::scandir($path, true, false);
		foreach ($files as $v) {
			$size += @\filesize($v);
		}
		return $size;
	}
1066152
protected function getImageSizeByExtension($file, $extension)
	{
		$extension = strtolower($extension);
		$this->loadExtension($extension);
		if (isset($this->classMap[$extension]))
		{
			$this->classMap[$extension]->getSize($file);
		}
	}
510628
public function checkFilename($file)
    {
        $newFilename  = $file;
        $parts        = pathinfo($file);
        $origFilename = $parts['filename'];
        $ext          = (isset($parts['extension']) && ($parts['extension'] != '')) ? '.' . $parts['extension'] : null;

        $i = 1;

        while (file_exists($this->uploadDir . DIRECTORY_SEPARATOR . $newFilename)) {
            $newFilename = $origFilename . '_' . $i . $ext;
            $i++;
        }

        return $newFilename;
    }
206791
protected function setFileSize($file)
    {
        $this->fileSize = ! is_null($this->elfinderFilePath) ? $this->getFileSize() : (is_string($file) ? $this->size($file) : $file->getClientSize());
    }
217807
public function getFilePath($file): string
    {
        if (null === ($fileObj = $this->container->get('huh.utils.file')->getFileFromUuid($file))) {
            return '';
        }

        return $fileObj->path;
    }
922751
public function get_file_size($source) {
        // TODO MDL-33297 remove this function completely?
        $browser    = get_file_browser();
        $params     = unserialize(base64_decode($source));
        $contextid  = clean_param($params['contextid'], PARAM_INT);
        $fileitemid = clean_param($params['itemid'], PARAM_INT);
        $filename   = clean_param($params['filename'], PARAM_FILE);
        $filepath   = clean_param($params['filepath'], PARAM_PATH);
        $filearea   = clean_param($params['filearea'], PARAM_AREA);
        $component  = clean_param($params['component'], PARAM_COMPONENT);
        $context    = context::instance_by_id($contextid);
        $file_info  = $browser->get_file_info($context, $component, $filearea, $fileitemid, $filepath, $filename);
        if (!empty($file_info)) {
            $filesize = $file_info->get_filesize();
        } else {
            $filesize = null;
        }
        return $filesize;
    }
727157
protected function getSize($file)
    {
        if (! file_exists($file)) {
            return [];
        }

        $info = pathinfo($file);
        $image = null;
        switch (strtolower($info['extension'])) {
            case 'gif':
                $image = imagecreatefromgif($file);
                break;
            case 'jpg':
            case 'jpeg':
                $image = imagecreatefromjpeg($file);
                break;
            case 'png':
                $image = imagecreatefrompng($file);
                break;
            default:
                break;
        }
        if ($image == null) {
            return [];
        } else {
            return [imagesx($image), imagesy($image)];
        }
    }
227246
function file_get_contents($file)
		{
			$fd = fopen($file, 'rb');
			$content = fread($fd, filesize($file));
			fclose($fd);
			$this->file_loaded_size+= strlen($content);
			return $content;				
		}
422204
private function getFullPath(string $file = null): string
	{
		return $this->getBasePath() . $this->path . ($file !== null ? DIRECTORY_SEPARATOR . $file : '');
	}
1238440
protected static function getFilesize($filesize)
    {
        $value = (float)($filesize);
        $unit = substr($filesize, -1);

        switch ($unit) {
            case 'K':
                return $value / 1024;
            case 'G':
                return $value * 1024;
            case 'M':
            default:
                return $value;
        }
    }
497023
public static function getExtension($file){

		$file = trim($file);
		$extension = strtolower(substr(strrchr($file, '.'), 1));

		if($extension == $file){

			return '';
		}
		else{

			return $extension;
		}
	}
1014605
public function getFileSize()
    {
        $oFile = oxNew(\OxidEsales\Eshop\Application\Model\File::class);
        $oFile->load($this->oxorderfiles__oxfileid->value);

        return $oFile->getSize();
    }
489671
public static function imageSize($file, $options)
    {
        if (!isset($options['height']) && !isset($options['width'])) {
            throw new InvalidArgumentException('Invalid image size validation parameters! Missing `width` and / or `height`.');
        }

        $filename = static::getFilename($file);

        list($width, $height) = getimagesize($filename);

        $validHeight = $validWidth = null;

        if (isset($options['height'])) {
            $validHeight = self::comparison($height, $options['height'][0], $options['height'][1]);
        }
        if (isset($options['width'])) {
            $validWidth = self::comparison($width, $options['width'][0], $options['width'][1]);
        }
        if ($validHeight !== null && $validWidth !== null) {
            return ($validHeight && $validWidth);
        }
        if ($validHeight !== null) {
            return $validHeight;
        }
        if ($validWidth !== null) {
            return $validWidth;
        }

        throw new InvalidArgumentException('The 2nd argument is missing the `width` and / or `height` options.');
    }
1114309
public static function getFileMimeType($file)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        if ($finfo) {
            $mime_type = finfo_file($finfo, $file);
            finfo_close($finfo);
            return $mime_type;
        }
        return false;
    }
806740
static public function getFileExt($file)
    {
        $s = strrchr($file, '.');
        if ($s === false)
        {
            return false;
        }
        return strtolower(trim(substr($s, 1)));
    }