From 286024db74c744ff00b531d5dca81734ef66e2d0 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 3 Apr 2015 11:40:04 +0200 Subject: [PATCH] Fix for allfinfo and parsStat for non Windows Fileservers Small update --- src/Parser.php | 5 +++++ src/Share.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/Parser.php b/src/Parser.php index 381c491..8b4de78 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -92,6 +92,11 @@ public function parseStat($output) { $size = 0; foreach ($output as $line) { list($name, $value) = explode(':', $line, 2); + // A line = explode statement may not fill all array elements + // properly. May happen when accessing non Windows Fileservers + $words = explode(':', $line, 2); + $name = isset($words[0]) ? $words[0] : ''; + $value = isset($words[1]) ? $words[1] : ''; $value = trim($value); if ($name === 'write_time') { $mtime = strtotime($value); diff --git a/src/Share.php b/src/Share.php index 025a843..7c24f9f 100644 --- a/src/Share.php +++ b/src/Share.php @@ -120,6 +120,12 @@ public function dir($path) { public function stat($path) { $escapedPath = $this->escapePath($path); $output = $this->execute('allinfo ' . $escapedPath); + // Windows and non Windows Fileserver may respond different + // to the allinfo command for directories. If the result is a single + // line = error line, redo it with a different allinfo parameter + if ($escapedPath == '""' && count($output) < 2) { + $output = $this->execute('allinfo ' . '"."'); + } if (count($output) < 3) { $this->parseOutput($output, $path); }