mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
use regular stat instead of fstat
This commit is contained in:
parent
7aa7b44b7c
commit
68c5ef5670
2 changed files with 17 additions and 7 deletions
|
|
@ -239,8 +239,9 @@ class NativeShare extends AbstractShare {
|
|||
*/
|
||||
public function read($source) {
|
||||
$this->connect();
|
||||
$handle = $this->state->open($this->buildUrl($source), 'r');
|
||||
return NativeStream::wrap($this->state, $handle, 'r');
|
||||
$url = $this->buildUrl($source);
|
||||
$handle = $this->state->open($url, 'r');
|
||||
return NativeStream::wrap($this->state, $handle, 'r', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -254,8 +255,9 @@ class NativeShare extends AbstractShare {
|
|||
*/
|
||||
public function write($source) {
|
||||
$this->connect();
|
||||
$handle = $this->state->create($this->buildUrl($source));
|
||||
return NativeStream::wrap($this->state, $handle, 'w');
|
||||
$url = $this->buildUrl($source);
|
||||
$handle = $this->state->create($url);
|
||||
return NativeStream::wrap($this->state, $handle, 'w', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,20 +32,27 @@ class NativeStream implements File {
|
|||
*/
|
||||
private $eof = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* Wrap a stream from libsmbclient-php into a regular php stream
|
||||
*
|
||||
* @param \Icewind\SMB\NativeState $state
|
||||
* @param resource $smbStream
|
||||
* @param string $mode
|
||||
* @param string $url
|
||||
* @return resource
|
||||
*/
|
||||
public static function wrap($state, $smbStream, $mode) {
|
||||
public static function wrap($state, $smbStream, $mode, $url) {
|
||||
stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeStream');
|
||||
$context = stream_context_create(array(
|
||||
'nativesmb' => array(
|
||||
'state' => $state,
|
||||
'handle' => $smbStream
|
||||
'handle' => $smbStream,
|
||||
'url' => $url
|
||||
)
|
||||
));
|
||||
$fh = fopen('nativesmb://', $mode, false, $context);
|
||||
|
|
@ -69,6 +76,7 @@ class NativeStream implements File {
|
|||
$context = stream_context_get_options($this->context);
|
||||
$this->state = $context['nativesmb']['state'];
|
||||
$this->handle = $context['nativesmb']['handle'];
|
||||
$this->url = $context['nativesmb']['url'];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +99,7 @@ class NativeStream implements File {
|
|||
|
||||
public function stream_stat() {
|
||||
try {
|
||||
return $this->state->fstat($this->handle);
|
||||
return $this->state->stat($this->url);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue