function isAbsolute($path) { $path = Fs :: cleanPath($path); $separator = Fs :: separator(); if($path{0} == $separator) return true; elseif(Sys :: osType() == 'win32' && preg_match('~^[a-zA-Z]+:~', $path)) return true; else return false; }
function testRecursiveFind() { $this->_createFileSystem(); $res = Fs :: recursiveFind(TEST_DIR_ABSOLUTE_PATH . '/tmp/', 'test\d_1'); sort($res); $this->assertEqual( $res, array( Fs :: cleanPath(TEST_DIR_ABSOLUTE_PATH . '/tmp/test1_1'), Fs :: cleanPath(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey/test3_1'), Fs :: cleanPath(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/test2_1'), ) ); $this->_removeFileSystem(); }
protected function _generateDebugEditorLinkHtml($code, $file_path) { if(!defined('WS_SCRIPT_WRITTEN')) { $code->writeHtml(' <SCRIPT LANGUAGE="JScript"> function run_template_editor(path) { WS = new ActiveXObject("WScript.shell"); WS.exec("uedit32.exe " + path); } </SCRIPT>'); define('WS_SCRIPT_WRITTEN', true); } if(Fs :: isPathRelative($file_path)) { $items = Fs :: explodePath($_SERVER['PATH_TRANSLATED']); array_pop($items); $file_path = Fs :: path($items) . Fs :: separator() . $file_path; } $file_path = addslashes(Fs :: cleanPath($file_path)); $code->writeHtml("<a href='#'><img onclick='runTemplateEditor(\"{$file_path}\");' src='/shared/images/i.gif' alt='{$file_path}' title='{$file_path}' border='0'></a>"); }
function testFlush() { $this->_writeSimpleCache('p_test1', $content1 = 'test-content1'); $this->_writeSimpleCache('p_test2', $content2 ='test-content2'); $this->_writeSimpleCache('not_page_file', $content3 ='test-content3'); $cache_manager = new PartialPageCacheManager(); $cache_manager->flush(); $files = Fs :: findSubitems(PAGE_CACHE_DIR); $this->assertEqual(sizeof($files), 1); $file = reset($files); $this->assertEqual(Fs :: cleanPath($file), Fs :: cleanPath(PAGE_CACHE_DIR . Fs :: separator() . 'not_page_file')); $this->_cleanSimpleCache('not_page_file'); }
function &_getRecursiveFileList($directory, $file_test_function) { if(!is_dir($directory)) return array(); $dh = opendir($directory); $file_list = array(); while ($file = readdir($dh)) { $file_path = $directory . '/' . $file; if (0 === strpos($file, '.')) continue; if (is_dir($file_path)) { $file_list = array_merge($file_list, $this->_getRecursiveFileList( $file_path, $file_test_function)); } if ($file_test_function[0]->$file_test_function[1]($file)) { $file_list[] = Fs :: cleanPath($file_path); } } closedir($dh); return $file_list; }