コード例 #1
0
 /**
  * Get the readline history file path.
  *
  * Defaults to `/history` inside the shell's base config dir unless
  * explicitly overridden.
  *
  * @return string
  */
 public function getHistoryFile()
 {
     if (isset($this->historyFile)) {
         return $this->historyFile;
     }
     foreach ($this->getConfigDirs() as $dir) {
         $file = $dir . '/psysh_history';
         if (@is_file($file)) {
             return $this->historyFile = $file;
         }
         $file = $dir . '/history';
         if (@is_file($file)) {
             return $this->historyFile = $file;
         }
     }
     // fallback: create our own
     if (isset($this->configDir)) {
         $dir = $this->configDir;
     } else {
         $xdg = new Xdg();
         $dir = $xdg->getHomeConfigDir();
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0700, true);
     }
     $file = $dir . '/psysh_history';
     return $this->historyFile = $file;
 }
コード例 #2
0
ファイル: Configuration.php プロジェクト: Zarbisi/todo
 /**
  * Get the readline history file path.
  *
  * Defaults to `/history` inside the shell's base config dir unless
  * explicitly overridden.
  *
  * @return string
  */
 public function getHistoryFile()
 {
     if (isset($this->historyFile)) {
         return $this->historyFile;
     }
     // Deprecation warning for incorrect psysh_history path.
     // projects: remove this before v0.8.0
     $xdg = new Xdg();
     $oldHistory = $xdg->getHomeConfigDir() . '/psysh_history';
     if (@is_file($oldHistory)) {
         $dir = $this->configDir ?: ConfigPaths::getCurrentConfigDir();
         $newHistory = $dir . '/psysh_history';
         $msg = sprintf("PsySH history file found at '%s'. Please delete it or move it to '%s'.", strtr($oldHistory, '\\', '/'), $newHistory);
         trigger_error($msg, E_USER_DEPRECATED);
         return $this->historyFile = $oldHistory;
     }
     $files = ConfigPaths::getConfigFiles(array('psysh_history', 'history'), $this->configDir);
     if (!empty($files)) {
         if ($this->warnOnMultipleConfigs && count($files) > 1) {
             $msg = sprintf('Multiple history files found: %s. Using %s', implode($files, ', '), $files[0]);
             trigger_error($msg, E_USER_NOTICE);
         }
         return $this->historyFile = $files[0];
     }
     // fallback: create our own history file
     $dir = $this->configDir ?: ConfigPaths::getCurrentConfigDir();
     if (!is_dir($dir)) {
         mkdir($dir, 0700, true);
     }
     return $this->historyFile = $dir . '/psysh_history';
 }
コード例 #3
0
 /**
  * Get a runtime directory.
  *
  * Defaults to  `/psysh` inside the system's temp dir.
  *
  * @return string
  */
 public static function getRuntimeDir()
 {
     $xdg = new Xdg();
     return $xdg->getRuntimeDir(false) . '/psysh';
 }
コード例 #4
0
 /**
  * Get potential data directory paths.
  *
  * If a `dataDir` option was explicitly set, returns an array containing
  * just that directory.
  *
  * Otherwise, it returns `~/.psysh` and all XDG Base Directory data directories:
  *
  *     http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
  *
  * @return string[]
  */
 protected function getDataDirs()
 {
     if (isset($this->dataDir)) {
         return array($this->dataDir);
     }
     $xdg = new Xdg();
     $dirs = array_map(function ($dir) {
         return $dir . '/psysh';
     }, $xdg->getDataDirs());
     if ($home = $this->getPsyHome()) {
         array_unshift($dirs, $home);
     }
     return $dirs;
 }
コード例 #5
0
ファイル: XdgGateway.php プロジェクト: shobcheye/sw-cli-tools
 /**
  * @return string
  */
 public function getRuntimeDir()
 {
     return $this->xdg->getRuntimeDir(false);
 }