To get a filesize in byte

@param string $filename

@return int
@throws FileNotFoundException
545934
public function size($filename)
    {
        if ($this->exists($filename) && $this->isFile($filename)) {
            return filesize($filename);
        }
        throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
    }
633951
function size($filename)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            return false;
        }

        $filename = $this->_realpath($filename);
        if ($filename === false) {
            return false;
        }

        return $this->_size($filename);
    }
1345447
protected function get_mimetype_from_filename($filename) {
        $mimetype = 'application/unknown';
        $types = core_filetypes::get_types();
        $fileextension = '.bin';
        if (strpos($filename, '.') !== false) {
            $fileextension = substr($filename, strrpos($filename, '.') + 1);
        }

        if (isset($types[$fileextension])) {
            $mimetype = $types[$fileextension]['type'];
        }
        return $mimetype;
    }
647703
public long size(String fileName) {
		try {
			IoChannel fileChannel = getFileChannel(fileName);
			return fileChannel.size() / BLOCK_SIZE;
		} catch (IOException e) {
			throw new RuntimeException("cannot access " + fileName);
		}
	}
882924
public static function sizeCount($filesize)
    {
        if ($filesize >= 1073741824)
        {
            $filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
        }
        elseif ($filesize >= 1048576)
        {
            $filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
        }
        elseif ($filesize >= 1024)
        {
            $filesize = round($filesize / 1024 * 100) / 100 . ' KB';
        }
        else
        {
            $filesize = $filesize . ' Bytes';
        }
        return $filesize;
    }
542269
function size($filename)
    {
        if (!($this->bitmap & SSH2::MASK_LOGIN)) {
            return false;
        }

        $result = $this->stat($filename);
        if ($result === false) {
            return false;
        }
        return isset($result['size']) ? $result['size'] : -1;
    }
132120
def size(filename, format='decimal'):
    '''
    

    '''
    if isinstance(filename, file):
        filename = filename.name

    return filesize(os.stat(filename)[stat.ST_SIZE], format)
1381
public static function make_human_readable_filesize($bytes) {
		$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
		$num_units = count($units);
		$size = $bytes;
		foreach ($units as $i => $unit) {
			if ($size < 1024 || (($i + 1) === $num_units)) {
				return round($size, 2).$unit;
			}
			$size = $size / 1024;
		}
		return $size;
	}
762954
function getFilesizeInBytes(fileName) {
    try {
        var stats = fs.statSync(fileName);
        return stats.size || 0;
    } catch (ex) {
        console.log(ex);
        return 0;
    }
}
438399
public static function filesize($filename, $decimals = 2)
    {
        $bytes = filesize($filename);
        $factor = floor((strlen($bytes) - 1) / 3);
        $size = 'BKMGTP';
        return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
    }
428429
public function checkSize($filesize)
    {
        if (is_string($filesize)) {
            $filesize = filesize($filesize);
        }
        return $filesize <= $this->allowedSize;
    }
1301396
public static function getImageDpi($filename)
    {
        $a = fopen($filename, 'r');
        $string = fread($a, 20);
        fclose($a);
        $data = bin2hex(mb_substr($string, 14, 4));
        $x = mb_substr($data, 0, 4);
        $y = mb_substr($data, 0, 4);

        return [hexdec($x), hexdec($y)];
    }
1186210
public function getSize() : int
    {
        $files = $this->getFiles();
        $size = 0;
        foreach($files as $file) {
            $size += $file->getSize();
        }
        return $size;
    }
335781
protected static function loadFileInMemory($fileName)
  {
    if (!preg_match('/\.ini$/i', $fileName)) {
      $fileName .= '.ini';
    }
    $found = 0;
    foreach (self::$storages as $priority => $substorages) {
      foreach ($substorages as $storage) {
        $data = parse_ini_file(sprintf('%s/%s/%s', $storage, self::$languageCode, $fileName));
        if ($data) {
          self::$translations = array_merge(self::$translations, $data);
          $found++;
        }
      }
    }
    return $found != 0;
  }
393038
public static function getFileSize($path)
    {
        if (is_file($path)) {
            return filesize($path);
        } elseif (substr($path, 0, 6) == 'ftp://') {
            return self::getFileSizeFtp($path);
        } elseif (substr($path, 0, 4) == 'http') {
            return self::getFileSizeHttp($path);
        } else {
            return 0;
        }
    }
261931
public function getRealFileSize($fileSize)
    {
        //B goes at the end because it's always matched otherwise
        $validUnits = array('KB', 'MB', 'GB', 'TB');
        $value = str_replace(' ', '', $fileSize);

        $replacements = array('');
        $pattern = '/(\d+)/';
        $data = preg_grep($pattern, array($value));

        foreach ($validUnits as $unit) {
            if (strpos($fileSize, $unit)) {
                switch($unit) {
                    case 'B':
                        return $data[0] * pow(1024, 0);
                    case 'KB':
                        return $data[0] * pow(1024, 1);
                    case 'MB':
                        return $data[0] * pow(1024, 2);
                    case 'GB':
                        return $data[0] * pow(1024, 3);
                    case 'TB':
                        return $data[0] * pow(1024, 4);
                }
            }
        }

        return $fileSize;
    }
306969
public static function getFileExtension($filename)
    {
        $filename = basename($filename);

        // remove possible query string
        $pos = strpos($filename, '?');
        if ($pos !== false) {
            $filename = substr($filename, 0, $pos);
        }

        // retrieve the extension
        $pos = strrpos($filename, '.');
        if ($pos !== false) {
            return strtolower(substr($filename, $pos + 1));
        }

        return '';
    }