mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
simplify parseStat
This commit is contained in:
parent
1e7809b74e
commit
98eff3b9b8
1 changed files with 7 additions and 16 deletions
|
|
@ -122,9 +122,7 @@ class Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseStat($output) {
|
public function parseStat($output) {
|
||||||
$mtime = 0;
|
$data = [];
|
||||||
$mode = 0;
|
|
||||||
$size = 0;
|
|
||||||
foreach ($output as $line) {
|
foreach ($output as $line) {
|
||||||
// A line = explode statement may not fill all array elements
|
// A line = explode statement may not fill all array elements
|
||||||
// properly. May happen when accessing non Windows Fileservers
|
// properly. May happen when accessing non Windows Fileservers
|
||||||
|
|
@ -132,20 +130,13 @@ class Parser {
|
||||||
$name = isset($words[0]) ? $words[0] : '';
|
$name = isset($words[0]) ? $words[0] : '';
|
||||||
$value = isset($words[1]) ? $words[1] : '';
|
$value = isset($words[1]) ? $words[1] : '';
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
if ($name === 'write_time') {
|
$data[$name] = $value;
|
||||||
$mtime = strtotime($value);
|
|
||||||
} else if ($name === 'attributes') {
|
|
||||||
$mode = hexdec(substr($value, strpos($value, '('), -1));
|
|
||||||
} else if ($name === 'stream') {
|
|
||||||
list(, $size,) = explode(' ', $value);
|
|
||||||
$size = intval($size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return array(
|
return [
|
||||||
'mtime' => $mtime,
|
'mtime' => strtotime($data['write_time']),
|
||||||
'mode' => $mode,
|
'mode' => hexdec(substr($data['attributes'], strpos($data['attributes'], '('), -1)),
|
||||||
'size' => $size
|
'size' => intval(explode(' ', $data['stream'])[1])
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseDir($output, $basePath) {
|
public function parseDir($output, $basePath) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue