]> _ Git - cubist_net.git/commitdiff
wip #5661
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 20 Jan 2023 14:05:05 +0000 (15:05 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 20 Jan 2023 14:05:05 +0000 (15:05 +0100)
src/SSH2.php

index 6dfa0d863e566d5c270ef2873c325236b4a8b0fc..27875acb6c27c035748155208354a89443bdbbb4 100644 (file)
@@ -101,6 +101,10 @@ class SSH2 {
                return $this->getSFTPWrapper() . ltrim($filename, '/');
        }
 
+       public function path($path) {
+               return $this->_filename($path);
+       }
+
        public function filesize($filename) {
                return filesize($this->_filename($filename));
        }
@@ -128,7 +132,16 @@ class SSH2 {
                }
                $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;
        }
 
        /**
@@ -137,10 +150,9 @@ class SSH2 {
         * @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);
@@ -157,9 +169,8 @@ class SSH2 {
                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);