Beispiel #1
0
 /**
  * Returns the content of a downloaded file as a TeamSpeak3_Helper_String object.
  *
  * @param  string  $key
  * @param  integer $size
  * @throws TeamSpeak3_Adapter_Exception
  * @return TeamSpeak3_Helper_String
  */
 public function download($ftkey, $size)
 {
     $this->init($ftkey);
     $buff = new TeamSpeak3_Helper_String("");
     $size = intval($size);
     $pack = 4096;
     for ($seek = 0; $seek < $size;) {
         $rest = $size - $seek;
         $pack = $rest < $pack ? $rest : $pack;
         $data = $this->getTransport()->read($rest < $pack ? $rest : $pack);
         $seek = $seek + $pack;
         $buff->append($data);
     }
     $this->getProfiler()->stop();
     if (strlen($buff) != $size) {
         throw new TeamSpeak3_Adapter_Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)");
     }
     return $buff;
 }