public function get($source, $target) {
		if (!$target) {
			throw new InvalidPathException('Invalid target path: Filename cannot be empty');
		}
		$targetHandle = @fopen($target, 'wb');
		if (!$targetHandle) {
			$error = error_get_last();
			if (is_array($error)) {
				$reason = $error['message'];
			} else {
				$reason = 'Unknown error';
			}
			throw new InvalidResourceException('Failed opening local file "' . $target . '" for writing: ' . $reason);
		}

		$sourceHandle = $this->getState()->open($this->buildUrl($source), 'r');
		if (!$sourceHandle) {
			fclose($targetHandle);
			throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading');
		}

		while ($data = $this->getState()->read($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
			fwrite($targetHandle, $data);
		}
		$this->getState()->close($sourceHandle);
		return true;
	}
public function get($source, $target) {
		if (!$target) {
			throw new InvalidPathException('Invalid target path: Filename cannot be empty');
		}
		$targetHandle = @fopen($target, 'wb');
		if (!$targetHandle) {
			$error = error_get_last();
			if (is_array($error)) {
				$reason = $error['message'];
			} else {
				$reason = 'Unknown error';
			}
			throw new InvalidResourceException('Failed opening local file "' . $target . '" for writing: ' . $reason);
		}

		$sourceHandle = $this->getState()->open($this->buildUrl($source), 'r');
		if (!$sourceHandle) {
			fclose($targetHandle);
			throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading');
		}

		while ($data = $this->getState()->read($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
			fwrite($targetHandle, $data);
		}
		$this->getState()->close($sourceHandle);
		return true;
	}
public function get ( $ source , $ target ) { if ( ! $ target ) { throw new InvalidPathException ( 'Invalid target path: Filename cannot be empty' ) ; } $ targetHandle = @ fopen ( $ target , 'wb' ) ; if ( ! $ targetHandle ) { $ error = error_get_last ( ) ; if ( is_array ( $ error ) ) { $ reason = $ error [ 'message' ] ; } else { $ reason = 'Unknown error' ; } throw new InvalidResourceException ( 'Failed opening local file "' . $ target . '" for writing: ' . $ reason ) ; } $ sourceHandle = $ this -> getState ( ) -> open ( $ this -> buildUrl ( $ source ) , 'r' ) ; if ( ! $ sourceHandle ) { fclose ( $ targetHandle ) ; throw new InvalidResourceException ( 'Failed opening remote file "' . $ source . '" for reading' ) ; } while ( $ data = $ this -> getState ( ) -> read ( $ sourceHandle , NativeReadStream :: CHUNK_SIZE ) ) { fwrite ( $ targetHandle , $ data ) ; } $ this -> getState ( ) -> close ( $ sourceHandle ) ; return true ; }
Download a remote file

@param string $source remove file
@param string $target local file
@return bool

@throws \Icewind\SMB\Exception\NotFoundException
@throws \Icewind\SMB\Exception\InvalidTypeException
@throws \Icewind\SMB\Exception\InvalidPathException
@throws \Icewind\SMB\Exception\InvalidResourceException
Download a remote file