diff options
-rw-r--r-- | config.php | 29 | ||||
-rw-r--r-- | library/FileHandler.php | 4 |
2 files changed, 24 insertions, 9 deletions
@@ -10,16 +10,17 @@ class Webgrind_Config{ * Automatically check if a newer version of webgrind is available for download */ static $checkVersion = true; - + /** - * Writable dir for information storage + * Writable dir for information storage. + * If empty, will use system tmp folder or xdebug tmp */ - static $storageDir = '/tmp/'; - + static $storageDir = ''; + /** * Suffix for preprocessed files */ - static $preprocessedSuffix = '.prep'; + static $preprocessedSuffix = '.webgrind'; static $defaultTimezone = 'Europe/Copenhagen'; static $dateFormat = 'Y-m-d H:i:s'; @@ -57,6 +58,20 @@ class Webgrind_Config{ * Directory to search for trace files */ static function xdebugOutputDir() { - return ini_get('xdebug.profiler_output_dir').'/'; - } + return realpath(ini_get('xdebug.profiler_output_dir')).'/'; + } + + /** + * Writable dir for information storage + */ + static function storageDir() { + if (!empty(Webgrind_Config::$storageDir)) + return realpath(Webgrind_Config::$storageDir).'/'; + + if (!function_exists('sys_get_temp_dir')) { + # use xdebug setting + return Webgrind_Config::xdebugOutputDir(); + } + return realpath(sys_get_temp_dir()).'/'; + } } diff --git a/library/FileHandler.php b/library/FileHandler.php index ca518e4..3aef45b 100644 --- a/library/FileHandler.php +++ b/library/FileHandler.php @@ -26,7 +26,7 @@ class Webgrind_FileHandler{ $files = $this->getFiles(Webgrind_Config::xdebugOutputFormat(), Webgrind_Config::xdebugOutputDir()); // Get list of preprocessed files - $prepFiles = $this->getFiles('/\\'.Webgrind_Config::$preprocessedSuffix.'$/', Webgrind_Config::$storageDir); + $prepFiles = $this->getFiles('/\\'.Webgrind_Config::$preprocessedSuffix.'$/', Webgrind_Config::storageDir()); // Loop over the preprocessed files. foreach($prepFiles as $fileName=>$prepFile){ @@ -107,7 +107,7 @@ class Webgrind_FileHandler{ * @return Webgrind_Reader Reader for $file */ public function getTraceReader($file, $costFormat){ - $prepFile = Webgrind_Config::$storageDir.$file.Webgrind_Config::$preprocessedSuffix; + $prepFile = Webgrind_Config::storageDir().$file.Webgrind_Config::$preprocessedSuffix; try{ $r = new Webgrind_Reader($prepFile, $costFormat); } catch (Exception $e){ |