/**
  * Traverses Files and Directories inside given path Recursively
  * @param $path to traverse
  */
 public function traverseDirFiles($path)
 {
     $dir = opendir($path);
     $files = array();
     $f = array();
     $skip = array(Fox::getDirectoryPath() . DS . "var", Fox::getDirectoryPath() . DS . "library" . DS . "Zend", Fox::getExtensionDirectoryPath(), Fox::getDirectoryPath() . DS . "theme" . DS . "installer", APPLICATION_PATH . DS . "views" . DS . "installer");
     while ($ft = readdir($dir)) {
         if (in_array($ft, array(".", "..")) || in_array($path . DS . $ft, $skip)) {
             continue;
         }
         $f[] = $ft;
     }
     sort($f);
     foreach ($f as $file) {
         if (filetype($path . DS . $file) != "dir") {
             $files[] = $file;
         } else {
             $this->traverseDirFiles($path . DS . $file);
         }
     }
     foreach ($files as $f) {
         $this->processFiles($path, $f);
     }
     closedir($dir);
 }
 /**
  * Get Installed package directory path
  * 
  * @return string
  */
 public function getInstalledPkgPath()
 {
     return Fox::getExtensionDirectoryPath() . DS . $this->getDownloaderDir() . DS . $this->config->downloader->installed_dir;
 }
 /**
  * Get Xml of site directories/files
  * 
  * @param bool $cache if true gets xml from cache otherwise regenerates
  * @return string xml string
  */
 public function getSiteXml($cache = true)
 {
     $xml = '';
     $conf = $this->getConfig()->getConfiguration();
     $cachePath = Fox::getExtensionDirectoryPath() . DS . $conf->extensionmanager->dir_name . DS . $conf->extensionmanager->cache;
     if (!file_exists($cachePath)) {
         @mkdir($cachePath, 0777, true);
     }
     $fileName = $cachePath . DS . $conf->extensionmanager->cache_file;
     if ($cache && file_exists($fileName)) {
         $xml = file_get_contents($fileName);
     } else {
         $path = Fox::getDirectoryPath();
         $Obj = new Fox_Extensionmanager_Model_Generate_DirectoryToXml($path);
         $Obj->traverseDirFiles($path);
         $Obj->setArray($Obj->arr);
         if (!($xml = $Obj->saveArrayToXml())) {
             throw new Exception("Unable to load content tree data.");
         }
         $dom = $Obj->getXMLDom();
         $dom->save($fileName);
         @chmod($fileName, 0777);
     }
     return trim(preg_replace('/<\\?xml.*\\?>/', '', $xml, 1));
 }