#! /usr/bin/env php config->uldl_dir_fanout; function finish_group($i) { global $now, $fanout, $flist; $dir = "tree_threader_template_".$now."_$i"; $dirpath = "/tmp/$dir"; $cmd = "zip -r $dirpath $dirpath"; system($cmd); $f = "$dir.zip"; $path = dir_hier_path($f, "download", $fanout); if (rename("/tmp/$f", $path)) { echo "renamed /tmp/$f to $path\n"; } else { die("can't rename /tmp/$f to $path\n"); } fprintf($flist, "$f\n"); } $dir = $argv[1]; $d = opendir($dir); $igp = 0; $gpsize = 0; while (($f = readdir($d)) !== false) { $p = "$dir/$f"; echo "processing $p\n"; if (!is_file($p)) continue; if ($gpsize == 0) { start_group($igp); } add_file_to_group($igp, $p); $gpsize++; if ($gpsize == $files_per_group) { finish_group($igp); $gpsize = 0; $igp++; } } if ($gpsize) { finish_group($igp); } fclose($flist); ?>