diff options
-rw-r--r-- | library/FileHandler.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/library/FileHandler.php b/library/FileHandler.php index 5e880bd..f855a75 100644 --- a/library/FileHandler.php +++ b/library/FileHandler.php @@ -51,12 +51,21 @@ class Webgrind_FileHandler{ * @return void string */ private function getInvokeUrl($file){ + if (preg_match('/.webgrind$/', $file)) + return 'Webgrind internal'; + // Grab name of invoked file. - // TODO: Makes assumptions about where the "cmd"-header is in a trace file. Not so cool, but a fast way to do it. $fp = fopen($file, 'r'); - fgets($fp); - $invokeUrl = trim(substr(fgets($fp), 5)); - fclose($fp); + $invokeUrl = ''; + while ((($line = fgets($fp)) !== FALSE) && !strlen($invokeUrl)){ + if (preg_match('/^cmd: (.*)$/', $line, $parts)){ + $invokeUrl = isset($parts[1]) ? $parts[1] : ''; + } + } + fclose($fp); + if (!strlen($invokeUrl)) + $invokeUrl = 'Unknown!'; + return $invokeUrl; } |