mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
Make NativeShare::getStat private to avoid confusion with NativeShare::stat
This commit is contained in:
parent
6e724b8986
commit
350e19c285
2 changed files with 20 additions and 13 deletions
|
|
@ -30,7 +30,10 @@ class NativeFileInfo implements IFileInfo {
|
||||||
/**
|
/**
|
||||||
* @var array|null
|
* @var array|null
|
||||||
*/
|
*/
|
||||||
protected $statCache;
|
protected $statCache = null;
|
||||||
|
|
||||||
|
/** @var callable|null */
|
||||||
|
protected $statCallback = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
|
|
@ -41,13 +44,20 @@ class NativeFileInfo implements IFileInfo {
|
||||||
* @param NativeShare $share
|
* @param NativeShare $share
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $stat
|
* @param array|callable $stat
|
||||||
*/
|
*/
|
||||||
public function __construct($share, $path, $name, $stat = null) {
|
public function __construct($share, $path, $name, $stat) {
|
||||||
$this->share = $share;
|
$this->share = $share;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
|
if (is_array($stat)) {
|
||||||
$this->statCache = $stat;
|
$this->statCache = $stat;
|
||||||
|
} else if (is_callable($stat)) {
|
||||||
|
$this->statCallback = $stat;
|
||||||
|
} else {
|
||||||
|
throw new \InvalidArgumentException('$stat needs to be an array or callback');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,7 +79,7 @@ class NativeFileInfo implements IFileInfo {
|
||||||
*/
|
*/
|
||||||
protected function stat() {
|
protected function stat() {
|
||||||
if (is_null($this->statCache)) {
|
if (is_null($this->statCache)) {
|
||||||
$this->statCache = $this->share->getStat($this->getPath());
|
$this->statCache = call_user_func($this->statCallback);
|
||||||
}
|
}
|
||||||
return $this->statCache;
|
return $this->statCache;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,10 @@ class NativeShare extends AbstractShare {
|
||||||
while ($file = $this->getState()->readdir($dh)) {
|
while ($file = $this->getState()->readdir($dh)) {
|
||||||
$name = $file['name'];
|
$name = $file['name'];
|
||||||
if ($name !== '.' and $name !== '..') {
|
if ($name !== '.' and $name !== '..') {
|
||||||
$files [] = new NativeFileInfo($this, $path . '/' . $name, $name);
|
$fullPath = $path . '/' . $name;
|
||||||
|
$files [] = new NativeFileInfo($this, $fullPath, $name, function() use ($fullPath) {
|
||||||
|
return $this->getStat($fullPath);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,13 +112,7 @@ class NativeShare extends AbstractShare {
|
||||||
return new NativeFileInfo($this, $path, basename($path), $this->getStat($path));
|
return new NativeFileInfo($this, $path, basename($path), $this->getStat($path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function getStat($path) {
|
||||||
* Get fstat
|
|
||||||
*
|
|
||||||
* @param string $path
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getStat($path) {
|
|
||||||
return $this->getState()->stat($this->buildUrl($path));
|
return $this->getState()->stat($this->buildUrl($path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue