From c9202f80e79a4bd1ddc0b0947b25aeff09a51538 Mon Sep 17 00:00:00 2001 From: Dmitry Buryak Date: Thu, 16 Jan 2014 14:53:29 +0300 Subject: [PATCH] Use local app data folder as home dir on windows --- Mtool/Magento.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Mtool/Magento.php b/Mtool/Magento.php index 6e204eb..d00c8ea 100644 --- a/Mtool/Magento.php +++ b/Mtool/Magento.php @@ -90,7 +90,20 @@ public function findInCode($search, $where = null) */ public static function getHomeDir() { - return $_SERVER['HOME']; + return static::isWindows() ? $_SERVER['LOCALAPPDATA'] : $_SERVER['HOME']; + } + + /** + * Check if os is windows + * + * @return bool + */ + public static function isWindows() + { + return + (defined('PHP_OS') && (substr_compare(PHP_OS, 'win', 0, 3, true) === 0)) || + (getenv('OS') != false && substr_compare(getenv('OS'), 'windows', 0, 7, true)) + ; } /**