获得文件大小

@param string $path
@return array
@author yangyifan <yangyifanphp@gmail.com>
172094
public function getSize($path)
    {
        $file_info = $this->getMetadata($path);
        return $file_info != false && $file_info['content-length'] > 0 ? [ 'size' => $file_info['content-length'] ] : ['size' => 0];
    }
1040506
public static function encode($path) {
        
        $lastLat = 0;
        $lastLng = 0;

        $result = '';

        foreach( $path as $point ) {
            $lat = round( $point['lat'] * 1e5);
            $lng = round( $point['lng'] * 1e5);
            
            $dLat = $lat - $lastLat;
            $dLng = $lng - $lastLng;

            self::enc($dLat);
            self::enc($dLng);

            $lastLat = $lat;
            $lastLng = $lng;
        }
        return self::$result;
    }
388628
public static function size($path)
    {
        $path = Normalize::diskFullPath($path);

        if (!self::exist($path)) {
            return 0;
        }

        return filesize($path);
    }
1231676
public function mimeType($path)
    {
        if ($this->isDirectory($path) || $path == '/') {
            return LocalFilesystem::$directoryMimetype;
        }
        return $this->mimeTypes->typeOfName($path);
    }
638005
protected function getFileInformation($path) {
    $file = pathinfo($path);

    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mimetype = finfo_file($finfo, $path);
    // Check if mimetype is supported.
    if (!in_array($mimetype, $this->valid_mimes)) {
      if ($mimetype == 'text/plain') {
        $mimetype = 'application/octet-stream';
      }
      else {
        $this->triggerError('Unsupported mime type: ' . $mimetype);
      }
    }

    $contents = file_get_contents($path);

    return [
      'name'      => str_replace(' ', '-', $file['filename']),
      'filename'  => $file['basename'],
      'extension' => $file['extension'],
      'mimetype'  => $mimetype,
      'contents'  => $contents,
      'size'      => strlen($contents)
    ];
  }
1294703
private function buildPath($path)
    {
        $result = [];
        foreach (explode('/', $path) as $value) {
            if (!empty($value)) {
                $result[] = (int) $value;
            }
        }
        return $result;
    }
1304951
private function pathinfo(string $path): array
    {
        $pathinfo = pathinfo($path) + compact('path');
        $pathinfo['dirname'] = array_key_exists('dirname', $pathinfo) ?
                            $this->normalizeDirname($pathinfo['dirname']) :
                            '';

        return $pathinfo;
    }
1369380
public static function size($path)
    {
        $path = Normalize::diskFullPath($path);
        if (!self::exist($path)) {
            return 0;
        }

        $size = 0;
        try {
            foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $file) {
                if ($file->getFileName() !== '..') {
                    $size += $file->getSize();
                }
            }
        } catch (\Exception $e) {
            return 0;
        }
        return $size;
    }
1178850
protected function getFiles($path)
    {
        $path = Str::finish($path, '/');

        if (file_exists($path . App::getLocale())) {
            return File::files($path . App::getLocale());
        } elseif (file_exists($path . config('app.fallback_locale'))) {
            return File::files($path . config('app.fallback_locale'));
        }

        return [];
    }
661996
protected function explode_path($path) {
        $parts = explode('/', $path, 2);
        if (isset($parts[1]) && $parts[1] !== '') {
            list($bucket, $uri) = $parts;
        } else {
            $bucket = $parts[0];
            $uri = '';
        }
        return array($bucket, $uri);
    }
408279
public static function parsePath($path)
    {
        $components = pathinfo($path);

        return [
            'directory' => isset($components['dirname']) ? self::fixPath($components['dirname']) : null,
            'filename' => isset($components['filename']) ? $components['filename'] : null,
            'extension' => isset($components['extension']) ? $components['extension'] : null,
        ];
    }
566975
public static function normalizePath($path)
    {
        if (is_string($path)) {
            return explode('.', $path);
        }

        if (!is_array($path)) {
            return [$path];
        }

        return $path;
    }
45304
public function read($path)
    {
        if ($response = $this->readStream($path)) {
            return ['contents' => stream_get_contents($response['stream']), 'path' => $response['path']];
        }

        return false;
    }
1048417
protected function normalizeMetaData($path)
    {
        $meta = $this->client->getObjectMeta($this->bucket, $path);
        if (is_null($meta)) {
            return false;
        }

        return [
            'path'      => $path,
            'timestamp' => strtotime($meta[strtolower('Last-Modified')]),
            'dirname'   => Util::dirname($path),
            'mimetype'  => $meta[strtolower('Content-Type')],
            'size'      => $meta[strtolower('Content-Length')],
            'type'      => 'file',
        ];
    }
622218
private function lsLegacy(string $path) : array
    {
        $list = [];
        foreach ($this->nlist($path) as $name) {
            $type   = $this->isDir($name) ? 'dir' : 'file';
            $size   = $this->size($name);
            $mtime  = $this->mdtm($name);

            if ($mtime == -1) {
                throw new RuntimeException('FTP server doesnt support \'ftp_mdtm\'');
            }

            $list[] = new File(['name' => $name, 'modify' => $mtime, 'type' => $type, 'size' => $size]);
        }
        return $list;
    }
109469
public static function size($path)
    {
        $path = ltrim(self::fullpath($path), '/');

        $ch = curl_init('file://' . $path);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_NOBODY, true);

        $headers = curl_exec($ch);
        curl_close($ch);

        $ch = null;

        if (preg_match('#content-length:(\s+?|)(\d+)#i', $headers, $matches)) {
            return $matches[2];
        }

        return false;
    }
1066442
protected function grabDirectorySize($path)
    {
        if (!is_dir($path)) {
            return [null, null];
        }

        $v         = preg_replace('/\s+.*$/', '', trim(`du -hs $path`));
        $readableV = $v;
        $matches   = null;

        if (preg_match('/^([0-9\.]+)([MGK])$/', $v, $matches)) {
            $v = (float) $matches[1];

            switch ($matches[2]) {
                case 'K':
                    $v *= 1024;
                    break;
                case 'M':
                    $v *= 1024;
                    $v *= 1024;
                    break;
                case 'G':
                    $v *= 1024;
                    $v *= 1024;
                    $v *= 1024;
                    break;
                default:
                    $v = null;
            }
        }

        return [$v ?: null, $readableV ?: null];
    }