Gets the filesize of a remote file.

        :param url:
            The url that has to be checked.
        :type url:
            String

        :returns:
            int
354651
def get_remote_file_size(self, url):
        
        headers = requests.head(url).headers
        return int(headers['content-length'])
1373239
public static function get_remote_filesize($url, $maxredirs = 2) {
		$parts = parse_url($url);
		if (empty($parts['host'])) {
			return false;
		}

		if ($parts['scheme'] === 'https') {
			$host = 'ssl://'.$parts['host'];
			$port = (isset($parts['port'])) ? $parts['port'] : 443;
		} else {
			$host = $parts['host'];
			$port = (isset($parts['port'])) ? $parts['port'] : 80;
		}
		$errno = $errstr = '';
		$timeout = 30;

		try {
			$fp = @fsockopen($host, $port, $errno, $errstr, $timeout);
		} catch (\Exception $e) {
			return false;
		}
		if (empty($fp)) {
			return false;
		}

		$path = $parts['path'];
		if (!empty($parts['query'])) {
			$path .= '?'.$parts['query'];
		}

		$out = 'HEAD '.$path.' HTTP/1.1'."\r\n"
			.'Host: '.$parts['host']."\r\n"
			.'Connection: Close'."\r\n\r\n";

		fwrite($fp, $out);
		$headers = '';
		while (!@feof($fp)) {
			$headers .= @fgets($fp, 128);
		}
		fclose($fp);

		$return = false;
		$headers = explode("\n", $headers);
		foreach ($headers as $header) {
			$hparts = explode(':', mb_strtolower($header), 2);
			if (!isset($hparts[1])) {
				continue;
			}
			list($hkey, $hval) = $hparts;
			switch ($hkey) {
				case 'location':
					if ($maxredirs > 0) {
						return static::get_remote_filesize(trim($hval), ($maxredirs - 1));
					} else {
						return false;
					}

				case 'content-length':
					return (int)trim($hval);
			}
		}
	}
237584
def get_size(path):
    
    if os.path.isfile(path):
        return os.path.getsize(path)
    return sum(get_size(os.path.join(path, f)) for f in os.listdir(path))
966556
def download_file(self, url):
        
        response = requests.get(url, stream=True)
        response.raise_for_status()
        return (int(response.headers.get('content-length', 0)), response)
545915
def get_size(self):
    
    if not self._is_open:
      raise IOError('Not opened.')

    if self._fsntfs_data_stream:
      return self._fsntfs_data_stream.get_size()
    return self._fsntfs_file_entry.get_size()
3424
def size(f, unit='B', fileStore=None):
    
    divisor = return_bytes(unit)
    fileID = process_infile(f, fileStore)[0]
    return fileID.size / divisor
1228563
def size(args):
    
    from jcvi.utils.cbook import human_size

    p = OptionParser(size.__doc__)
    fp = sys.stdin

    results = []
    for link_name in fp:
        link_name = link_name.strip()
        if not op.islink(link_name):
            continue

        source = get_abs_path(link_name)

        link_name = op.basename(link_name)
        filesize = op.getsize(source)
        results.append((filesize, link_name))

    # sort by descending file size
    for filesize, link_name in sorted(results, reverse=True):
        filesize = human_size(filesize, a_kilobyte_is_1024_bytes=True)
        print("%10s\t%s" % (filesize, link_name), file=sys.stderr)
408492
def get_file_size(self, fid):
        
        url = self.get_file_url(fid)
        res = self.conn.head(url)
        if res is not None:
            size = res.headers.get("content-length", None)
            if size is not None:
                return int(size)
        return None
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
880246
public static long length(URL url) throws IOException {
	HTTPResponse http = HTTPEngine.head(url, null, null, -1, true, null, Constants.NAME, null, null);
	long len = http.getContentLength();
	HTTPEngine.closeEL(http);
	return len;
    }
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
496309
def size(self):
        
        tot = 0
        for p in self.__iter__(overPath=True):
            tot += os.path.getsize(p)
        return tot
1256495
def check_file_size(file_size, path):
        
        stat_info = os.stat(path)
        if stat_info.st_size != file_size:
            format_str = "Error occurred downloading {}. Got a file size {}. Expected file size:{}"
            msg = format_str.format(path, stat_info.st_size, file_size)
            raise ValueError(msg)
41817
def _get_filename_from_url(url):
    
    parse = urlparse(url)
    return os.path.basename(parse.path)
132120
def size(filename, format='decimal'):
    '''
    

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

    return filesize(os.stat(filename)[stat.ST_SIZE], format)
316875
def size(self):
        """"""
        total_size = 0
        for dir_path, dir_names, filenames in os.walk(self.dir):
            for f in filenames:
                fp = os.path.join(dir_path, f)
                total_size += os.path.getsize(fp)
        return total_size
700260
def get_size(self):
        
        if self._size is None:
            self._size = self._filepath.stat().st_size
        return self._size