mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
Work around issue where 'allinfo' keeps the file open
This commit is contained in:
parent
6629a780b0
commit
ededbfbaa3
5 changed files with 57 additions and 6 deletions
|
|
@ -10,6 +10,16 @@ namespace Icewind\SMB;
|
|||
use Icewind\SMB\Exception\ConnectionException;
|
||||
|
||||
class RawConnection {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $env;
|
||||
|
||||
/**
|
||||
* @var resource[] $pipes
|
||||
*
|
||||
|
|
@ -24,6 +34,12 @@ class RawConnection {
|
|||
private $process;
|
||||
|
||||
public function __construct($command, $env = array()) {
|
||||
$this->command = $command;
|
||||
$this->env = $env;
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
private function connect() {
|
||||
$descriptorSpec = array(
|
||||
0 => array('pipe', 'r'), // child reads from stdin
|
||||
1 => array('pipe', 'w'), // child writes to stdout
|
||||
|
|
@ -33,13 +49,13 @@ class RawConnection {
|
|||
5 => array('pipe', 'w') // child writes to fd#5
|
||||
);
|
||||
setlocale(LC_ALL, Server::LOCALE);
|
||||
$env = array_merge($env, array(
|
||||
$env = array_merge($this->env, array(
|
||||
'CLI_FORCE_INTERACTIVE' => 'y', // Needed or the prompt isn't displayed!!
|
||||
'LC_ALL' => Server::LOCALE,
|
||||
'LANG' => Server::LOCALE,
|
||||
'COLUMNS' => 8192 // prevent smbclient from line-wrapping it's output
|
||||
));
|
||||
$this->process = proc_open($command, $descriptorSpec, $this->pipes, '/', $env);
|
||||
$this->process = proc_open($this->command, $descriptorSpec, $this->pipes, '/', $env);
|
||||
if (!$this->isValid()) {
|
||||
throw new ConnectionException();
|
||||
}
|
||||
|
|
@ -138,6 +154,11 @@ class RawConnection {
|
|||
proc_close($this->process);
|
||||
}
|
||||
|
||||
public function reconnect() {
|
||||
$this->close();
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
$this->close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue