/** * Set cache * * @param string $key * @param mixed $value * @param int $ttl * @return boolean */ public function set($key, $value) { if (!is_string($value)) { $value = serialize($value); } $file = $this->_file($key); $dir = dirname($file); is_dir($dir) || Cola_Com_Fs::mkdir($dir); return file_put_contents($file, $value) ? true : false; }
protected function _handler($text) { $dir = dirname($this->_options['file']); is_dir($dir) || Cola_Com_Fs::mkdir($dir, $this->_options['mode']); return file_put_contents($this->_options['file'], $text . "\n", FILE_APPEND | LOCK_EX); }
/** * Move file * * @param array $file * @param string $name * @return boolean */ protected function _move($file, $name = null) { if (!$this->check($file)) { return false; } if (null === $name) { $name = $file['name']; } $fileFullName = $this->_config['savePath'] . DIRECTORY_SEPARATOR . $name; if (file_exists($fileFullName) && !$this->_config['override']) { $msg = 'file_already_exits:' . $fileFullName; $this->_error[] = $msg; return false; } $dir = dirname($fileFullName); is_dir($dir) || Cola_Com_Fs::mkdir($dir); if (is_writable($dir) && move_uploaded_file($file['tmp_name'], $fileFullName)) { $this->_num++; return true; } $this->_error[] = 'move_uploaded_file_failed:' . $dir . 'may not be writeable.'; return false; }