function process_dir($dir, $recursive = FALSE) { if (is_dir($dir)) { for ($list = array(), $handle = opendir($dir); FALSE !== ($file = readdir($handle));) { if ($file != '.' && $file != '..' && $file != 'level.dat.json' && $file != 'level.dat.json.gz' && file_exists($path = $dir . '/' . $file)) { if (is_dir($path) && $recursive) { $list = array_merge($list, process_dir($path, TRUE)); } else { $entry = array('filename' => $file); //---------------------------------------------------------// // - SECTION 1 - // // Actions to be performed on ALL ITEMS // //----------------- Begin Editable ------------------// //$entry['modtime'] = filemtime($path); //----------------- End Editable ------------------// do { if (!is_dir($path)) { //---------------------------------------------------------// // - SECTION 2 - // // Actions to be performed on FILES ONLY // //----------------- Begin Editable ------------------// //$entry['size'] = filesize($path); $pos = strpos($path, '.b6z'); $pos2 = strpos($path, '.gz'); if ($pos > 0 | $pos2 > 0) { unlink($path); continue; } $pos3 = strpos($file, 'evel.dat'); if ($pos3 > 0) { continue; } $entry['dat'] = readchunk($path); $entry['filename'] = trimpath($path); //----------------- End Editable ------------------// break; } else { //---------------------------------------------------------// // - SECTION 3 - // // Actions to be performed on DIRECTORIES ONLY // //----------------- Begin Editable ------------------// //----------------- End Editable ------------------// break; } } while (FALSE); //if ($entry['dat'] & $entry['dat']['xpos'] ) $list[] = $entry; } } } closedir($handle); return $list; } else { return FALSE; } }
function process_dir($dir) { $srcdir = $dir; echo "processing dir : {$srcdir} <br>"; if ($curdir = opendir($srcdir)) { while ($file = readdir($curdir)) { if ($file != '.' && $file != '..') { $srcfile = $srcdir . '\\' . $file; if (is_file($srcfile)) { convert_file($srcfile); } else { if (is_dir($srcfile)) { process_dir($srcfile); } } } } } closedir($curdir); }
function process_dir($dir, $recursive = FALSE) { if (is_dir($dir)) { for ($list = array(), $handle = opendir($dir); FALSE !== ($file = readdir($handle));) { if ($file != '.' && $file != '..' && file_exists($path = $dir . '/' . $file)) { if (is_dir($path) && $recursive) { $list = array_merge($list, process_dir($path, TRUE)); } else { $entry = array('filename' => $file, 'dirpath' => $dir); //---------------------------------------------------------// // - SECTION 1 - // // Actions to be performed on ALL ITEMS // //----------------- Begin Editable ------------------// // var_dump($entry); $entry['modtime'] = filemtime($path); //----------------- End Editable ------------------// do { if (!is_dir($path)) { //---------------------------------------------------------// // - SECTION 2 - // // Actions to be performed on FILES ONLY // //----------------- Begin Editable ------------------// $entry['size'] = filesize($path); if (strstr(pathinfo($path, PATHINFO_BASENAME), '.log')) { if (!($entry['handle'] = fopen($path, 'r'))) { $entry['handle'] = "FAIL"; } } //----------------- End Editable ------------------// break; } else { //---------------------------------------------------------// // - SECTION 3 - // // Actions to be performed on DIRECTORIES ONLY // //----------------- Begin Editable ------------------// //----------------- End Editable ------------------// break; } } while (FALSE); $list[] = $entry; } } } closedir($handle); return $list; } else { return FALSE; } }
<?php include 'config.php'; # # build a list of maps for us to construct # $map = array(); $dh = opendir($pngs); while ($file = readdir($dh)) { if ($file != '.' && $file != '..' && is_dir("{$pngs}/{$file}")) { process_dir($pngs, $file, $map); } } closedir($dh); function process_dir($pngs, $dir, &$map) { $files = array(); $dh = opendir("{$pngs}/{$dir}"); while ($file = readdir($dh)) { if (preg_match('!^(.*?)_?(\\d\\d)_(\\d\\d)\\.png$!', $file, $m)) { $key = StrToLower($dir . '__' . $m[1]); $map[$key]["{$m['2']}-{$m['3']}"] = "{$pngs}/{$dir}/{$file}"; $files[] = $file; } } closedir($dh); # make preview $out = ""; foreach ($files as $file) { $out .= "<img src=\"{$file}\" style=\"border: 1px solid red\" >\n"; }
<?php include 'config.php'; $pngs = $crushed; # # build a list of maps for us to sync # $dh = opendir($pngs); while ($file = readdir($dh)) { if ($file != '.' && $file != '..' && is_dir("{$pngs}/{$file}")) { process_dir($pngs, $file); } } closedir($dh); function process_dir($pngs, $dir) { global $s3_cmd; global $s3_bucket; if ($dir != 'azeroth') { return; } echo "{$dir}: \n"; $dh = opendir("{$pngs}/{$dir}"); while ($file = readdir($dh)) { if (preg_match('!^tile_z(\\d)_(\\d\\d)_(\\d\\d)\\.png$!', $file, $m)) { $args = "--acl-public --guess-mime-type --add-header='Expires:Fri, 10 Jan 2020 23:30:00 GMT' --add-header='Cache-Control:max-age=315360000, public'"; $cmd = "{$s3_cmd} {$args} put {$pngs}/{$dir}/{$file} {$s3_bucket}/{$dir}/{$file}"; exec($cmd, $ret, $code); if ($code) { echo "\n" . implode("\n", $ret) . "\n"; } else {
$place = $this->mapping[$type]; $node = $this->data->ItemGroup[$place]->addChild($type); $node['Include'] = $file; $this->files[$type][$file] = true; return true; } } $old = getcwd(); chdir(__DIR__); if (!file_exists('pspautotests.vcxproj')) { echo 'Oops, where\'s pspautotests.vcxproj?', "\n"; exit(1); } $proj = new VCXProjectFile('pspautotests.vcxproj'); $filters = new FiltersFile('pspautotests.vcxproj.filters'); process_dir('../tests', $proj, $filters); $proj->save(); $filters->save(); chdir($old); function process_dir($path, $proj, $filters) { $paths = git_files($path); // Git not working / not installed? Warning: this gives us full paths. if (empty($paths)) { // Intentionally not doing this when not VERBOSE. if (VERBOSE) { echo 'WARN: git ls-files failed, falling back.', "\n"; $paths = fallback_files($path); } else { echo 'WARN: git ls-files failed.', "\n"; }
function process_dir($host, $user, $password, $root, $level, $proc) { global $PROCESSING_EXTS; if ($level <= 0) { return; } print "Processing: {$root}\n"; list($dirs, $files) = list_dir($host, $user, $password, $root); if (sizeof($dirs) > 0 && sizeof($files) > 0) { //~ #~ print dirs, files //~ #~ print len(dirs), len(files) fsave("ok_accounts.txt", implode("\t", array($host, $user, $password, $root)) . "\n", true); foreach ($dirs as $d) { process_dir($host, $user, $password, $root . "/" . $d, $level - 1, $proc); } foreach ($files as $f) { foreach ($PROCESSING_EXTS as $i) { if (strpos($f, $i) !== false) { process_file($host, $user, $password, $root . "/" . $f, $proc); break; } } } } else { fsave("fail_accounts.txt", implode("\t", array($host, $user, $password, $root)) . "\n", true); } }