本文整理汇总了PHP中dir::walk_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP dir::walk_dir方法的具体用法?PHP dir::walk_dir怎么用?PHP dir::walk_dir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dir
的用法示例。
在下文中一共展示了dir::walk_dir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function test_walk_dir()
{
$this->_create_file_system();
$mock =& new special_dir_walker($this);
$mock->expectCallCount('walk', 9+2);
if(sys :: os_type() == 'win32')
{
$mock->expectArgumentsAt(0, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp'), 'test1_1', array('test', 'separator' => dir :: separator()), array(0)));
$mock->expectArgumentsAt(1, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp'), 'test1_2', array('test', 'separator' => dir :: separator()), array(0, 1)));
$mock->expectArgumentsAt(2, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp'), 'test1_3', array('test', 'separator' => dir :: separator()), array(0, 1, 2)));
$mock->expectArgumentsAt(3, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp'), 'wow', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3)));
$mock->expectArgumentsAt(4, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow'), 'hey', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4)));
$mock->expectArgumentsAt(5, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey'), 'test3_1', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5)));
$mock->expectArgumentsAt(6, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey'), 'test3_2', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6)));
$mock->expectArgumentsAt(7, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey'), 'test3_3', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6, 7)));
$mock->expectArgumentsAt(8, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow'), 'test2_1', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6, 7, 8)));
$mock->expectArgumentsAt(9, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow'), 'test2_2', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)));
$mock->expectArgumentsAt(10, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow'), 'test2_3', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
}
elseif(sys :: os_type() == 'unix')
{
$mock->expectArgumentsAt(0, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp'), 'wow', array('test', 'separator' => dir :: separator()), array(0)));
$mock->expectArgumentsAt(1, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow'), 'hey', array('test', 'separator' => dir :: separator()), array(0, 1)));
$mock->expectArgumentsAt(2, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey'), 'test3_1', array('test', 'separator' => dir :: separator()), array(0, 1, 2)));
$mock->expectArgumentsAt(3, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey'), 'test3_2', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3)));
$mock->expectArgumentsAt(4, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey'), 'test3_3', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4)));
$mock->expectArgumentsAt(5, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow'), 'test2_1', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5)));
$mock->expectArgumentsAt(6, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow'), 'test2_2', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6)));
$mock->expectArgumentsAt(7, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow'), 'test2_3', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6, 7)));
$mock->expectArgumentsAt(8, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp'), 'test1_1', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6, 7, 8)));
$mock->expectArgumentsAt(9, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp'), 'test1_2', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)));
$mock->expectArgumentsAt(10, 'walk', array(dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp'), 'test1_3', array('test', 'separator' => dir :: separator()), array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
}
$this->assertEqual(
dir :: walk_dir(TEST_DIR_ABSOLUTE_PATH . '/tmp/', array(&$mock, 'walk'), array('test')),
array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
);
$mock->tally();
$this->_remove_file_system();
}
示例2: walk_dir
function walk_dir($dir, $function_def, $params = array())
{
static $separator = '';
if (!$separator) {
$separator = dir::separator();
}
if (is_dir($dir)) {
$handle = opendir($dir);
while (($file = readdir($handle)) !== false) {
if ($file != '.' && $file != '..') {
if (is_dir($dir . $separator . $file)) {
dir::walk_dir($dir . $separator . $file . $separator, $function_def, $params);
}
call_user_func_array($function_def, array('dir' => $dir, 'file' => $file, 'params' => $params));
}
}
closedir($handle);
}
}
示例3: _load_actions
function _load_actions($dir_name)
{
dir::walk_dir($dir_name, array(&$this, '_add_action'));
}
示例4: walk_dir
function walk_dir($dir, $function, $args = array())
{
if (is_dir($dir)) {
$handle = opendir($dir);
$separator = dir::separator();
while (($file = readdir($handle)) !== false) {
if ($file != "." && $file != "..") {
if (is_dir($file)) {
dir::walk_dir($dir . $separator . $file . $separator, $function);
}
if (function_exists($function)) {
call_user_func($function, $dir, $file, $args);
}
}
}
closedir($handle);
}
}