mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
code reuse
This commit is contained in:
parent
5e073449ee
commit
1bf43bf0a3
1 changed files with 4 additions and 19 deletions
|
|
@ -274,15 +274,8 @@ class Share extends AbstractShare {
|
||||||
$source = $this->escapePath($source);
|
$source = $this->escapePath($source);
|
||||||
// since returned stream is closed by the caller we need to create a new instance
|
// 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
|
// since we can't re-use the same file descriptor over multiple calls
|
||||||
$workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : '';
|
$connection = $this->getConnection();
|
||||||
$command = sprintf('%s %s --authentication-file=%s %s',
|
|
||||||
$this->system->getSmbclientPath(),
|
|
||||||
$workgroupArgument,
|
|
||||||
System::getFD(3),
|
|
||||||
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
|
|
||||||
);
|
|
||||||
$connection = new Connection($command, $this->parser);
|
|
||||||
$connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
|
|
||||||
$connection->write('get ' . $source . ' ' . System::getFD(5));
|
$connection->write('get ' . $source . ' ' . System::getFD(5));
|
||||||
$connection->write('exit');
|
$connection->write('exit');
|
||||||
$fh = $connection->getFileOutputStream();
|
$fh = $connection->getFileOutputStream();
|
||||||
|
|
@ -303,17 +296,9 @@ class Share extends AbstractShare {
|
||||||
$target = $this->escapePath($target);
|
$target = $this->escapePath($target);
|
||||||
// since returned stream is closed by the caller we need to create a new instance
|
// 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
|
// since we can't re-use the same file descriptor over multiple calls
|
||||||
$workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : '';
|
$connection = $this->getConnection();
|
||||||
$command = sprintf('%s %s --authentication-file=%s %s',
|
|
||||||
$this->system->getSmbclientPath(),
|
|
||||||
$workgroupArgument,
|
|
||||||
System::getFD(3),
|
|
||||||
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
|
|
||||||
);
|
|
||||||
$connection = new Connection($command, $this->parser);
|
|
||||||
$connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
|
|
||||||
$fh = $connection->getFileInputStream();
|
|
||||||
|
|
||||||
|
$fh = $connection->getFileInputStream();
|
||||||
$connection->write('put ' . System::getFD(4) . ' ' . $target);
|
$connection->write('put ' . System::getFD(4) . ' ' . $target);
|
||||||
$connection->write('exit');
|
$connection->write('exit');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue