summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjokkedk <joakim@jokke.dk>2008-06-18 22:20:48 +0000
committerjokkedk <joakim@jokke.dk>2008-06-18 22:20:48 +0000
commit272b1f4e504aecb3b80c4c5dc8484814ffa4d087 (patch)
tree5e07acd1cbd745f93f56ee496d2ac2291ea4c4d6
parentebfc573ec57b50aca1d51be6e75918c4a137f72a (diff)
downloadwebgrind-272b1f4e504aecb3b80c4c5dc8484814ffa4d087.zip
webgrind-272b1f4e504aecb3b80c4c5dc8484814ffa4d087.tar.gz
webgrind-272b1f4e504aecb3b80c4c5dc8484814ffa4d087.tar.bz2
- Improved autodetection of profile output dir
- Added autodetection of tmp storage dr
-rw-r--r--config.php29
-rw-r--r--library/FileHandler.php4
2 files changed, 24 insertions, 9 deletions
diff --git a/config.php b/config.php
index 226b214..639076c 100644
--- a/config.php
+++ b/config.php
@@ -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){