Get size of a given file.
@param string path to file
@param string format
@example size('folder/log.txt')
@example size('folder/log.txt', 'kb')
@example size('folder.log.txt', 'mb')
@return int size of file in given format
769150
public static function size($file = false, $format = 'bytes') {

        if ($file && self::isFile($file)) {

            $size = filesize($file);

            switch ($format) {
                case 'bytes':
                    return $size;
                    break;
                case 'kb':
                    return Number::round(($size / 1024), 2);
                    break;
                case 'mb':
                    return Number::round(($size / 1048576), 2);
                    break;
            }
        }

        return false;
    }
1106253
def get_file_size(filename):
    
    if os.path.isfile(filename):
        return convert_size(os.path.getsize(filename))
    return None
120754
def _get_file_size(file_path):
    

    size = getsize(file_path)

    file_size = bytearray(4)
    pack_into(b"I", file_size, 0, size)

    return file_size
929839
public function getProsize(String $path, Int $width = 0, Int $height = 0) : stdClass
    {
        # If the image file is not found, an exception is thrown.
        $this->throwExceptionImageFileIfNotExists($path);

        # Get image size.
        $getImageCoordinate = getimagesize($path);

        # It gives the width and height value proportional to the width value of the picture.
        $x = $getImageCoordinate[0];
        $y = $getImageCoordinate[1];

        CoordinateRateCalculator::run($width, $x, $y);

        # It gives the width and height value proportional to the height value of the picture.
        CoordinateRateCalculator::run($height, $x, $y);

        # Return width & height
        return (object) 
        [
            'width'  => round($x),
            'height' => round($y)
        ];
    }
848247
public function getSize($path)
    {
        list($fsize, , , ) = array_values($this->getMetadata($path));
        return $fsize > 0 ? [ 'size' => $fsize ] : ['size' => 0];
    }
993149
public static String getReadableFileSize(int size) {
        final int BYTES_IN_KILOBYTES = 1024;
        final DecimalFormat dec = new DecimalFormat("###.#");
        final String KILOBYTES = " KB";
        final String MEGABYTES = " MB";
        final String GIGABYTES = " GB";
        float fileSize = 0;
        String suffix = KILOBYTES;

        if (size > BYTES_IN_KILOBYTES) {
            fileSize = size / BYTES_IN_KILOBYTES;
            if (fileSize > BYTES_IN_KILOBYTES) {
                fileSize = fileSize / BYTES_IN_KILOBYTES;
                if (fileSize > BYTES_IN_KILOBYTES) {
                    fileSize = fileSize / BYTES_IN_KILOBYTES;
                    suffix = GIGABYTES;
                } else {
                    suffix = MEGABYTES;
                }
            }
        }
        return String.valueOf(dec.format(fileSize) + suffix);
    }
705314
def file_size(path, rel = nil)
      return 0 if path.nil?
      path = path =~ /\// ? path : File.join('episodes', path)
      path = rel + path if rel
      File.size(path)
    end
1370471
public function getFileSize(string $path) : int
    {
        if (!$this->exists($path)) {
            throw new FileSystemException("File at path $path not found");
        }

        $fileSize = filesize($path);

        if ($fileSize === false) {
            throw new FileSystemException("Failed to get file size of $path");
        }

        return $fileSize;
    }
535645
public function getReadableFilesize()
    {
        $size = $this->filesize;
        if ($size < 1) {
            return $size;
        }

        if ($size < 1024) {
            return $size.'b';
        } else {
            $help = $size / 1024;
            if ($help < 1024) {
                return round($help, 1).'kb';
            } else {
                return round(($help / 1024), 1).'mb';
            }
        }
    }
1056599
function (path) {
    if ($bc_.pN) {
      var _path = path || ($bc_.pN.path.tempDir() + 'tmp.txt')
      return $bc_.pN.app.fileSizeAtPath(_path)
    }

    return ''
  }
118020
public function getSize($path)
    {
        $meta = $this->getMetadata($path);
        return ($meta && isset($meta['size'])) ? $meta : false;
    }
1066092
def size(pathname):
    
    if os.path.isfile(pathname):
        return os.path.getsize(pathname)
    return sum([size('{}/{}'.format(pathname, name)) for name in get_content_list(pathname)])
786058
def getsize(path, recurse=False):
    """"""
    if not op.isdir(path):
        return op.getsize(path)
    size = 0
    for r,_,fs in os.walk(path):
        for f in fs:
            size += getsize(op.join(r,f))
        if not recurse:
            break
    return size
921344
public static long getSize(File file) {
        if (file.exists()) {
            if (!file.isFile()) {
                long size = 0;
                File[] files = file.listFiles();
                if (files != null && files.length > 0) {
                    for (File f : files) {
                        size += getSize(f);
                    }
                }
                return size;
            } else {
                return file.length();
            }
        }
        return 0;
    }
1346540
public function size(string $path): Promise
    {
        if (!@\file_exists($path)) {
            return new Failure(new FilesystemException(
                "Path does not exist"
            ));
        }

        if (!@\is_file($path)) {
            return new Failure(new FilesystemException(
                "Path is not a regular file"
            ));
        }

        if (($size = @\filesize($path)) === false) {
            return new Failure(new FilesystemException(
                \error_get_last()["message"]
            ));
        }

        \clearstatcache(true, $path);
        return new Success($size);
    }
717771
def getsize(self, path):
        
        try:
            file_obj = self.filesystem.resolve(path)
            if (self.filesystem.ends_with_path_separator(path) and
                    S_IFMT(file_obj.st_mode) != S_IFDIR):
                error_nr = (errno.EINVAL if self.filesystem.is_windows_fs
                            else errno.ENOTDIR)
                self.filesystem.raise_os_error(error_nr, path)
            return file_obj.st_size
        except IOError as exc:
            raise os.error(exc.errno, exc.strerror)
1071876
public function getSize($format = true)
    {
        if ($format) {
            return Conversion::formatSizeUnits($this->result['size_download']);
        }
        return $this->result['size_download'];
    }