Get File Size

@param string $path
@param string $type = 'b' - options[b|kb|mb|gb]

@return float
346579
public function fileSize(String $path, String $type = 'b', Int $decimal = 2) : Float
    {
        $size = 0;

        $extension = Filesystem::getExtension($path);

        if( ! empty($extension) )
        {
            $size = ftp_size($this->connect, $path);
        }
        else
        {
            if( $this->files($path) )
            {
                foreach( $this->files($path) as $val )
                {
                    $size += ftp_size($this->connect, $path."/".$val);
                }

                $size += ftp_size($this->connect, $path);
            }
            else
            {
                $size += ftp_size($this->connect, $path);
            }
        }

        switch( $type )
        {
            case 'b' : return $size;
            case 'kb': return round($size / 1024, $decimal);
            case 'mb': return round($size / (1024 * 1024), $decimal);
            case 'gb': return round($size / (1024 * 1024 * 1024), $decimal);
        }
    }
1182776
def file_size(f):
    
    if isinstance(f, (six.string_types, six.text_type)):
        return os.path.getsize(f)
    else:
        cur = f.tell()
        f.seek(0, 2)
        size = f.tell()
        f.seek(cur)
        return size
1321037
public function size( $path )
	{
		try {
			return $this->fs->size( $path );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
1028393
protected function getContentOfType(string $path, int $type): ?vfsStreamContent
    {
        $content = $this->getContent($path);
        if (null !== $content && $content->getType() === $type) {
            return $content;
        }

        return null;
    }
118110
public function getImageSize($path, $mime = '') {
		$size = false;
		if ($mime === '' || strtolower(substr($mime, 0, 5)) === 'image') {
			if ($work = $this->getWorkFile($path)) {
				if ($size = @getimagesize($work)) {
					$size['dimensions'] = $size[0].'x'.$size[1];
				}
			}
			is_file($work) && @unlink($work);
		}
		return $size;
	}
739484
public static function getTypeFromFile(string $path): string
    {
        if (!is_file($path) || !is_readable($path)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'path'; ".
                "expecting an absolute path to a readable file"
            );
        }

        $finfo = new \finfo(FILEINFO_MIME_TYPE);
        $type = @$finfo->file($path);
        return ($type === false) ? "application/octet-stream" : $type;
    }
1163120
public static function getFileSize($path)
    {
        if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
            if (class_exists('COM')) {
                $fsobj = new COM('Scripting.FileSystemObject');
                $f = $fsobj->GetFile(realpath($path));
                $size = $f->Size;
            } else {
                $size = trim(exec("for %F in (\"" . $path . "\") do @echo %~zF"));
            }
        } elseif (PHP_OS == 'Darwin') {
            $size = trim(shell_exec("stat -f %z " . escapeshellarg($path)));
        } elseif (in_array(PHP_OS, [ 'Linux', 'FreeBSD', 'Unix', 'SunOS'])) {
            $size = trim(shell_exec("stat -c%s " . escapeshellarg($path)));
        } else {
            $size = filesize($path);
        }

        return doubleval($size);
    }
1140061
public static function ImageSize($Path, $Filename = FALSE) {
      if (!$Filename)
         $Filename = $Path;
      
      if (in_array(strtolower(pathinfo($Filename, PATHINFO_EXTENSION)), array('gif', 'jpg', 'jpeg', 'png'))) {
         $ImageSize = @getimagesize($Path);
         if (!is_array($ImageSize) || !in_array($ImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)))
            return array(0, 0, FALSE);
         return $ImageSize;
      }
      return array(0, 0, FALSE);
   }
492284
protected function getImageDimensions($type, $size)
	{
		$pathToImage = public_path($this->getImageConfig($type, $size, 'dir') . $this->$type);
		if (is_file($pathToImage) && file_exists($pathToImage))
		{
			list($width, $height) = getimagesize($pathToImage);
		}
		else
		{
			$width = $height = false;
		}
		return array($width, $height);
	}
119725
public function getImageHeight($type, $size)
	{
		if (empty($this->$type))
		{
			return null;
		}
		$method = $this->getImageConfig($type, $size, 'method');

		// Height varies for images that are 'landscape', 'auto', 'fit', 'crop'
		if (in_array($method, array('landscape', 'auto', 'fit', 'crop')))
		{
			list($width, $height) = $this->getImageDimensions($type, $size);
			return $height;
		}
		return $this->getImageConfig($type, $size, 'height');
	}
1286836
public static function getFileExt($path, $type = self::MIME_FINFO)
    {
        $mime = self::getFileMime($path, $type);
        return $mime ? self::mimeToExt($mime) : null;
    }
453176
public static function file($path, $type = null)
    {
        $response = new self(
            Status::OK,
            new PhpStream($path, 'rb')
        );
        if (isset($type)) {
            $response->setHeader('Content-Type', $type);
        }
        return $response;
    }
888025
public static function directorySize($path){
		$bytestotal = 0;
		$path = realpath($path);
		if($path!==false && $path!='' && file_exists($path)){
			foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS)) as $object){
				$bytestotal += $object->getSize();
			}
		}
		return $bytestotal;
	}
1147627
def get_size(path):
    ''''''
    size = os.path.getsize(path)
    for item in os.walk(path):
        for file in item[2]:
            size += os.path.getsize(os.path.join(item[0], file))
    return size
693316
protected function getType($path)
    {
        if (Str::endsWith($path, Type::CSV)) {
            return Type::CSV;
        } elseif (Str::endsWith($path, Type::ODS)) {
            return Type::ODS;
        } else {
            return Type::XLSX;
        }
    }
874103
protected function countSize($path) {
		$stat = $this->stat($path);

		if (empty($stat) || !$stat['read'] || !empty($stat['hidden'])) {
			return 'unknown';
		}
		
		if ($stat['mime'] != 'directory') {
			return $stat['size'];
		}
		
		$subdirs = $this->options['checkSubfolders'];
		$this->options['checkSubfolders'] = true;
		$result = 0;
		foreach ($this->getScandir($path) as $stat) {
			$size = $stat['mime'] == 'directory' && $stat['read'] 
				? $this->countSize($this->_joinPath($path, $stat['name'])) 
				: $stat['size'];
			if ($size > 0) {
				$result += $size;
			}
		}
		$this->options['checkSubfolders'] = $subdirs;
		return $result;
	}
37079
public function getImageWidth($type, $size)
	{
		if (empty($this->$type))
		{
			return null;
		}
		$method = $this->getImageConfig($type, $size, 'method');

		// Width varies for images that are 'portrait', 'auto', 'fit', 'crop'
		if (in_array($method, array('portrait', 'auto', 'fit', 'crop')))
		{
			list($width) = $this->getImageDimensions($type, $size);
			return $width;
		}
		return $this->getImageConfig($type, $size, 'width');
	}