Esempio n. 1
0
 /**
  * Returns a path without leading / or C:\. If this is not
  * present the path is returned as is.
  * 
  * @static
  * @access  public 
  * @param   string  $path The path to be processed
  * @return  string  The processed path or the path as is
  */
 function skipRoot($path)
 {
     if (File_Util::isAbsolute($path)) {
         if (FILE_WIN32) {
             return substr($path, $path[3] == '\\' ? 4 : 3);
         }
         return ltrim($path, '/');
     }
     return $path;
 }
Esempio n. 2
0
 /**
  * @deprecated      Use File_Util::isAbsolute() instead.
  */
 function isAbsolute($path)
 {
     require_once 'File/Util.php';
     return File_Util::isAbsolute($path);
 }
Esempio n. 3
0
 /**
  * Constructor
  *
  * @param   mixed   $db         SQLiteDatabase のインスタンス or データベースのパス
  * @param   array   $options    キャッシュ設定オプション (optional)
  * @throws  Cache_SQLiteException
  * @access  public
  */
 public function __construct($db = ':memory:', $options = array())
 {
     // エラー管理オブジェクトを用意
     $this->_stack = PEAR_ErrorStack::singleton('Cache_SQLite');
     // オプションを設定
     $constOptions = array('debug', 'strict', 'autoCreateTable', 'autoVacuum');
     foreach ($this->_defaults as $key => $value) {
         $propName = '_' . $key;
         $this->{$propName} = $value;
         if (isset($options[$key])) {
             if ($key == 'table') {
                 $this->{$propName} = (string) $options[$key];
             } elseif (in_array($key, $constOptions)) {
                 $this->{$propName} = (bool) $options[$key];
             } else {
                 $this->setOption($key, $options[$key]);
             }
         }
     }
     $this->_tableQuoted = self::_quoteIdentifier($this->_table);
     $this->_validFromat = self::SERIALIZE_PHP | self::ENCODE_BASE64 | self::ENCODE_ZLIB_BINARY;
     // データベースをオープン
     $errmsg = '';
     if ($db instanceof SQLiteDatabase) {
         $this->_db = $db;
     } else {
         if ($db == ':memory:' || File_Util::isAbsolute($db)) {
             $path = $db;
         } else {
             $path = File_Util::realPath($db);
         }
         $this->_db = new SQLiteDatabase($path, CACHE_SQLITE_FILE_MODE, $errmsg);
     }
     if ($errmsg == '') {
         $this->_inTransaction = false;
         if ($this->_autoCreateTable) {
             $this->_checkTable();
         }
     } else {
         $params = array('message' => $errmsg);
         $msg = 'sqlite_open() failed: %message%';
         $this->_stack->push(self::ERR_CRITICAL, 'error', $params, $msg);
         throw new Cache_SQLiteException('Cache_SQLite sqlite_open() failed: {$errmsg}', self::ERR_CRITICAL);
     }
 }