mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +02:00
fix support for smbclient compiled without readline support
This commit is contained in:
parent
9f6b8f1c3f
commit
a8dc9ca75b
6 changed files with 60 additions and 43 deletions
|
|
@ -345,11 +345,17 @@ class Share extends AbstractShare {
|
|||
// since returned stream is closed by the caller we need to create a new instance
|
||||
// since we can't re-use the same file descriptor over multiple calls
|
||||
$connection = $this->getConnection();
|
||||
stream_set_blocking($connection->getOutputStream(), false);
|
||||
|
||||
$connection->write('get ' . $source . ' ' . $this->system->getFD(5));
|
||||
$connection->write('exit');
|
||||
$fh = $connection->getFileOutputStream();
|
||||
stream_context_set_option($fh, 'file', 'connection', $connection);
|
||||
$fh = CallbackWrapper::wrap($fh, function() use ($connection) {
|
||||
$connection->write('');
|
||||
});
|
||||
if (!is_resource($fh)) {
|
||||
throw new Exception("Failed to wrap file output");
|
||||
}
|
||||
return $fh;
|
||||
}
|
||||
|
||||
|
|
@ -374,7 +380,9 @@ class Share extends AbstractShare {
|
|||
|
||||
// use a close callback to ensure the upload is finished before continuing
|
||||
// this also serves as a way to keep the connection in scope
|
||||
$stream = CallbackWrapper::wrap($fh, null, null, function () use ($connection) {
|
||||
$stream = CallbackWrapper::wrap($fh, function() use ($connection) {
|
||||
$connection->write('');
|
||||
}, null, function () use ($connection) {
|
||||
$connection->close(false); // dont terminate, give the upload some time
|
||||
});
|
||||
if (is_resource($stream)) {
|
||||
|
|
@ -446,7 +454,7 @@ class Share extends AbstractShare {
|
|||
* @return string[]
|
||||
*/
|
||||
protected function execute(string $command): array {
|
||||
$this->connect()->write($command . PHP_EOL);
|
||||
$this->connect()->write($command);
|
||||
return $this->connect()->read();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue