Gets the size of a remote file
@param string $remote_file path to remote file
@return integer The size of the file in bytes
495684
public function size($remote_file)
    {
        $size = @ftp_size($this->connection, $remote_file);
        if ($size && $size != -1) {
            return $size;
        } else {
            throw new \Exception("Could not get remote file size: " . $path);
        }
    }
608210
public function rename($remote_file_path, $new_remote_file_path)
    {
        //get file string massage
        $remote_file_path = self::winslashes($remote_file_path);
    $new_remote_file_path = self::winslashes($new_remote_file_path);
    $this->execute('rename "'.$remote_file_path.'" "'.$new_remote_file_path.'"', $output);
    return $output;
    }
743046
def _compute_remote_size(self, options):
        # type: (Descriptor, blobxfer.models.options.Upload) -> None
        
        size = self.local_path.size
        if (self._ase.mode == blobxfer.models.azure.StorageModes.Page and
                self.local_path.use_stdin):
            if options.stdin_as_page_blob_size == 0:
                allocatesize = _MAX_PAGE_BLOB_SIZE
                self._needs_resize = True
            else:
                allocatesize = options.stdin_as_page_blob_size
        elif size > 0:
            if self._ase.is_encrypted:
                # cipher_len_without_iv = (clear_len / aes_bs + 1) * aes_bs
                allocatesize = (size // self._AES_BLOCKSIZE + 1) * \
                    self._AES_BLOCKSIZE
            else:
                allocatesize = size
        else:
            allocatesize = 0
        self._ase.size = allocatesize
        if blobxfer.util.is_not_empty(self._ase.replica_targets):
            for rt in self._ase.replica_targets:
                rt.size = allocatesize
        if self._verbose:
            logger.debug('remote size for {} is {} bytes'.format(
                self._ase.path, self._ase.size))
922751
public function get_file_size($source) {
        // TODO MDL-33297 remove this function completely?
        $browser    = get_file_browser();
        $params     = unserialize(base64_decode($source));
        $contextid  = clean_param($params['contextid'], PARAM_INT);
        $fileitemid = clean_param($params['itemid'], PARAM_INT);
        $filename   = clean_param($params['filename'], PARAM_FILE);
        $filepath   = clean_param($params['filepath'], PARAM_PATH);
        $filearea   = clean_param($params['filearea'], PARAM_AREA);
        $component  = clean_param($params['component'], PARAM_COMPONENT);
        $context    = context::instance_by_id($contextid);
        $file_info  = $browser->get_file_info($context, $component, $filearea, $fileitemid, $filepath, $filename);
        if (!empty($file_info)) {
            $filesize = $file_info->get_filesize();
        } else {
            $filesize = null;
        }
        return $filesize;
    }
1050207
public function get_imageinfo(stored_file $file) {
        if (!$this->is_image_from_storedfile($file)) {
            return false;
        }

        // Whilst get_imageinfo_from_path can use remote paths, it must download the entire file first.
        // It is more efficient to use a local file when possible.
        return $this->get_imageinfo_from_path($this->get_local_path_from_storedfile($file, true));
    }
186564
def getsize(o_file):
    
    startpos = o_file.tell()
    o_file.seek(0)
    o_file.seek(0, SEEK_END)
    size = o_file.tell()
    o_file.seek(startpos)
    return size
1324661
public function getSize() : int
    {
        $size = -1;

        if ($this->isFile()) {
            $size = filesize($this->realPath);
        }

        return $size;
    }
1224521
def getbinaryfile(remotefile, localfile = File.basename(remotefile),
		      blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
      if @resume
	rest_offset = File.size?(localfile)
	f = open(localfile, "a")
      else
	rest_offset = nil
	f = open(localfile, "w")
      end
      begin
	f.binmode
	retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data|
	  f.write(data)
	  yield(data) if block
	end
      ensure
	f.close
      end
    end
809276
public static function getImageSize($name)
    {
        if (isset($_FILES[$name])) {
            $tempFile = $_FILES[$name]['tmp_name'];
            if (!empty($tempFile) && file_exists($tempFile)) {
                $size = getimagesize($tempFile);

                return $size;
            }
        }

        return getimagesize($name);
    }
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);
			}
		}
	}
386346
function _size($filename)
    {
        $result = $this->_stat($filename, NET_SFTP_LSTAT);
        if ($result === false) {
            return false;
        }
        return isset($result['size']) ? $result['size'] : -1;
    }
1135832
def get_remote_file(url):
    
    try:
        return requests.get(url)
    except requests.exceptions.ConnectionError as e:
        print("Connection error!")
        print(e.message.reason)
        exit(1)
831063
public function filesize()
	{
		if (!$this->filename)
		{
			throw new \RuntimeException('File not open');
		}

		// Capture PHP errors
		$php_errormsg = '';
		$track_errors = ini_get('track_errors');
		ini_set('track_errors', true);
		$res = @filesize($this->filename);

		if (!$res)
		{
			$tmp_error = '';

			if ($php_errormsg)
			{
				// Something went wrong.
				// Store the error in case we need it.
				$tmp_error = $php_errormsg;
			}

			$res = Helper::remotefsize($this->filename);

			if (!$res)
			{
				if ($tmp_error)
				{
					// Use the php_errormsg from before
					throw new \RuntimeException($tmp_error);
				}
				else
				{
					// Error but nothing from php? How strange! Create our own
					throw new \RuntimeException('Failed to get file size. This may not work for all streams.');
				}
			}
			else
			{
				$this->filesize = $res;
				$retval = $res;
			}
		}
		else
		{
			$this->filesize = $res;
			$retval = $res;
		}

		// Restore error tracking to what it was before.
		ini_set('track_errors', $track_errors);

		// Return the result
		return $retval;
	}
938330
public function get($remote_file = null, $local_file = null, $mode = FTP_ASCII)
    {
        if (\ftp_get($this->_stream, $local_file, $remote_file, $mode)) {
            return true;
        }

        $this->error = 'Failed to download file "'.$remote_file.'"';

        return false;
    }
1181436
def remote_file_size(self, remote_cmd="", remote_file=None):
        """"""
        if remote_file is None:
            if self.direction == "put":
                remote_file = self.dest_file
            elif self.direction == "get":
                remote_file = self.source_file
        if not remote_cmd:
            remote_cmd = "dir {}/{}".format(self.file_system, remote_file)
        remote_out = self.ssh_ctl_chan.send_command(remote_cmd)
        # Strip out "Directory of flash:/filename line
        remote_out = re.split(r"Directory of .*", remote_out)
        remote_out = "".join(remote_out)
        # Match line containing file name
        escape_file_name = re.escape(remote_file)
        pattern = r".*({}).*".format(escape_file_name)
        match = re.search(pattern, remote_out)
        if match:
            line = match.group(0)
            # Format will be 26  -rw-   6738  Jul 30 2016 19:49:50 -07:00  filename
            file_size = line.split()[2]
        if "Error opening" in remote_out or "No such file or directory" in remote_out:
            raise IOError("Unable to find file on remote system")
        else:
            return int(file_size)
284082
public function isWritable($remote_file)
    {
        $this->errorHandler->start();

        //remove slashes at beginning and end of dir's, beginning of file
        $dir = substr($this->configuration->getDir(), 0, 1) == '/' ? substr($this->configuration->getDir(), 1) : $this->configuration->getDir();
        $dir = substr($dir, -1, 1) == '/' ? substr($dir, 0, -1) : $dir;
        $remote_file = substr($remote_file, 0, 1) == '/' ? substr($remote_file, 1) : $remote_file;

        //get path info setup properly.
        $dirname = pathinfo('/' . $dir . '/' . $remote_file);
        $dirname = $dirname['dirname'];

        //get a directory listing and check that the file in question is listed (workaround for file_exists)
        $dirlist = $this->driver->nlist($this->resource, $dirname);
        if (is_array($dirlist) && in_array("/$dir/$remote_file", $dirlist)) {
            //file exists, check if we can open the file for appending
            if (!$handle = $this->driver->fopen($dir . '/' . $remote_file, 'a', $this->configuration)) {
                $this->errorHandler->stop();

                return false;
            }

            //attempt to do an empty append
            if (!fwrite($handle, '') === FALSE) {
                $this->errorHandler->stop();

                return false;
            }
            $this->errorHandler->stop();

            return true;
        }

        //file not found, return false
        $this->errorHandler->stop();

        return false;
    }
642288
public int getSize() {
		if (size < 0) {
			size = 0;
			for (byte[] cache: start) {
				size += new RemoteOneFileCache(cache).getSize();
			}
			for (byte[] cache: end) {
				size += new RemoteOneFileCache(cache).getSize();
			}
		}
		return size;
	}