function getCacheFile() { $cache_file = VAR_DIR . '/resolvers/' . get_class($this->_resolver) . '.php'; Fs :: mkdir(VAR_DIR . '/resolvers/'); return $cache_file; }
function CacheFilePersister($id = 'cache') { parent :: CachePersister($id); $this->cache_dir = VAR_DIR . '/' . $id; Fs :: mkdir($this->cache_dir); }
function writeTemplateFile($file, $data) { if(!is_dir(dirname($file))) Fs :: mkdir(dirname($file), 0777, true); $fp = fopen($file, "wb"); if (fwrite($fp, $data, strlen($data))) fclose($fp); }
public function getCache() { if ($this->cache) { return $this->cache; } include_once 'Cache/Lite.php'; include_once LIMB_DIR . '/class/lib/system/Fs.class.php'; Fs::mkdir(VAR_DIR . '/shipping_options'); $options = array('cacheDir' => VAR_DIR . '/shipping_options/', 'lifeTime' => $this->cache_life_time); $this->cache = new CacheLite($options); return $this->cache; }
public function store($disk_file_path) { if (!file_exists($disk_file_path)) { throw new FileNotFoundException('file not found', $disk_file_path); } srand(time()); $media_id = md5(uniqid(rand())); Fs::mkdir(MEDIA_DIR); $media_file = $this->getMediaFilePath($media_id); if (!copy($disk_file_path, $media_file)) { throw new IOException('copy failed', array('dst' => $media_file, 'src' => $disk_file_path)); } return $media_id; }
function write($log_file_data, $string) { $log_dir = $log_file_data[0]; $log_name = $log_file_data[1]; $file_name = $log_dir . $log_name; if (!is_dir($log_dir)) Fs :: mkdir($log_dir, 0775, true); $oldumask = umask(0); $file_existed = file_exists($file_name); $log_file = fopen($file_name, 'a'); if ($log_file) { $time = gmstrftime("%b %d %Y %H:%M:%S", time()); $notice = '[ ' . $time . " ]\n"; $toolkit =& Limb :: toolkit(); $user =& $toolkit->getUser(); if(($user_id = $user->getId()) != DEFAULT_USER_ID) $notice .= '[ ' . $user_id . ' ] [ ' . $user->getLogin() . ' ] [ ' . $user->get('email', '') . ' ] '; $notice .= '[' . Sys::clientIp() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n"; fwrite($log_file, $notice); fclose($log_file ); if (!$file_existed) chmod($file_name, 0664); umask($oldumask); $result = true; } else { umask($oldumask); return throw_error(new IOException("Cannot open log file '$file_name' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '$file_name' is disabled.")); } return $result; }
function testMkdirRelativePathNoTrailingSlash() { Fs :: rm(TEST_DIR_RELATIVE_PATH . '/tmp/'); $this->assertFalse(is_dir(TEST_DIR_RELATIVE_PATH . '/tmp/wow/hey/')); Fs :: mkdir(TEST_DIR_RELATIVE_PATH . '/./tmp\../tmp/wow////hey'); $this->assertTrue(is_dir(TEST_DIR_RELATIVE_PATH . '/tmp/wow/hey/')); }
function _createTmpMedia($media_id) { Fs::mkdir(MEDIA_DIR); touch(MEDIA_DIR . $media_id . '.media'); }
function _loadCache() { $this->reset(); $cache_dir = $this->cache_dir; Fs :: mkdir($cache_dir); if(catch_error('IOException', $e)) { Debug :: writeWarning('could not create cache directory for ini', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('cache_dir' => $cache_dir)); $this->_parse(); return; } if($override_file = $this->getOverrideFile()) $this->cache_file = $this->cache_dir . md5($override_file) . '.php'; else $this->cache_file = $this->cache_dir . md5($this->file_path) . '.php'; if ($this->_isCacheValid()) { $charset = null; $group_values = array(); include($this->cache_file); $this->charset = $charset; $this->group_values = $group_values; unset($group_values); } else { $this->_parse(); $this->_saveCache(); } }
function _writeSimpleCache($file_id, $contents) { Fs :: mkdir(PAGE_CACHE_DIR); $f = fopen(PAGE_CACHE_DIR . $file_id, 'w'); fwrite($f, $contents); fclose($f); }
function _writeMediaFile($media_id) { Fs :: mkdir(MEDIA_DIR); $f = fopen(MEDIA_DIR . $media_id . '.media', 'w'); fwrite($f, 'test'); fclose($f); }
public function getCacheSize() { Fs :: mkdir(PAGE_CACHE_DIR); $files = Fs :: findSubitems(PAGE_CACHE_DIR, 'f', '~^[^p]~'); $size = 0; foreach($files as $file) { $size += (filesize($file)); } return $size; }
function cp($src, $dest, $as_child = false, $include_regex = '', $exclude_regex = '', $include_hidden = false) { if (!is_dir($src)) return throw_error(new IOException('no such a directory', array('dir' => $src))); Fs :: mkdir($dest); $src = Fs :: normalizePath($src); $dest = Fs :: normalizePath($dest); $separator = Fs :: separator(); if($as_child) { $separator_regex = preg_quote($separator); if (preg_match( "#^.+{$separator_regex}([^{$separator_regex}]+)$#", $src, $matches)) { Fs :: _doMkdir($dest . $separator . $matches[1], 0777); $dest .= $separator . $matches[1]; } else return false; } $items = Fs :: find($src, 'df', $include_regex, $exclude_regex, false, $include_hidden); $total_items = $items; while (count($items) > 0) { $current_items = $items; $items = array(); foreach ($current_items as $item) { $full_path = $src . $separator . $item; if (is_file( $full_path)) copy($full_path, $dest . $separator . $item); elseif (is_dir( $full_path)) { Fs :: _doMkdir($dest . $separator . $item, 0777); $new_items = Fs :: find($full_path, 'df', $include_regex, $exclude_regex, $item, $include_hidden); $items = array_merge($items, $new_items); $total_items = array_merge($total_items, $new_items); unset($new_items); } } } if($total_items) clearstatcache(); return $total_items; }