コード例 #1
0
ファイル: NativeStream.php プロジェクト: evanjt/core
 public function stream_read($count)
 {
     $result = $this->state->read($this->handle, $count);
     if (strlen($result) < $count) {
         $this->eof = true;
     }
     return $result;
 }
コード例 #2
0
ファイル: NativeShare.php プロジェクト: ZverAleksey/core
 /**
  * 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
  */
 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);
     }
     $this->connect();
     $sourceHandle = $this->state->open($this->buildUrl($source), 'r');
     if (!$sourceHandle) {
         fclose($targetHandle);
         throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading');
     }
     while ($data = $this->state->read($sourceHandle, 4096)) {
         fwrite($targetHandle, $data);
     }
     $this->state->close($sourceHandle);
     return true;
 }
コード例 #3
0
ファイル: NativeShare.php プロジェクト: nuernbergerA/SMB
 /**
  * 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
  */
 public function get($source, $target)
 {
     $this->connect();
     $sourceHandle = $this->state->open($this->buildUrl($source), 'r');
     $targetHandle = fopen($target, 'wb');
     while ($data = $this->state->read($sourceHandle, 4096)) {
         fwrite($targetHandle, $data);
     }
     $this->state->close($sourceHandle);
     return true;
 }