return $this->getSFTPWrapper() . ltrim($filename, '/');
}
+ public function path($path) {
+ return $this->_filename($path);
+ }
+
public function filesize($filename) {
return filesize($this->_filename($filename));
}
}
$dir = dirname($remote);
$this->mkdir($dir);
- return copy($local, $this->_filename($remote));
+ return $this->_copy($local, $this->_filename($remote));
+ }
+
+ protected function _copy($from, $to, $send = true) {
+ if (class_exists('Cubist\Util\Files\Files')) {
+ $res = \Cubist\Util\Files\Files::copyFile($from, $to);
+ } else {
+ $res = copy($from, $to);
+ }
+ return $res;
}
/**
* @return bool
*/
public function recv($remote, $local) {
- return copy($this->_filename($remote), $local);
+ return $this->_copy($this->_filename($remote), $local, false);
}
-
public function unlink($file) {
if ($this->file_exists($file)) {
return ssh2_sftp_unlink($this->getSFTPConnection(), $file);
stream_set_blocking($errorStream, true);
stream_set_blocking($stream, true);
- // Whichever of the two below commands is listed first will receive its appropriate output. The second command receives nothing
- $res = array('output' => stream_get_contents($stream),
- 'error' => stream_get_contents($errorStream));
+ $stream_size_limit = 100000;
+ $res=['output'=>fread($stream,$stream_size_limit),'error'=>fread($errorStream,$stream_size_limit)];
// Close the streams
fclose($errorStream);