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) {
|
||||
$mtime = 0;
|
||||
$mode = 0;
|
||||
$size = 0;
|
||||
$data = [];
|
||||
foreach ($output as $line) {
|
||||
// A line = explode statement may not fill all array elements
|
||||
// properly. May happen when accessing non Windows Fileservers
|
||||
|
|
@ -132,20 +130,13 @@ class Parser {
|
|||
$name = isset($words[0]) ? $words[0] : '';
|
||||
$value = isset($words[1]) ? $words[1] : '';
|
||||
$value = trim($value);
|
||||
if ($name === 'write_time') {
|
||||
$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);
|
||||
}
|
||||
$data[$name] = $value;
|
||||
}
|
||||
return array(
|
||||
'mtime' => $mtime,
|
||||
'mode' => $mode,
|
||||
'size' => $size
|
||||
);
|
||||
return [
|
||||
'mtime' => strtotime($data['write_time']),
|
||||
'mode' => hexdec(substr($data['attributes'], strpos($data['attributes'], '('), -1)),
|
||||
'size' => intval(explode(' ', $data['stream'])[1])
|
||||
];
|
||||
}
|
||||
|
||||
public function parseDir($output, $basePath) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue