Exemplo n.º 1
0
 /**
  * Processing dir recursive
  * @param string $root Root dir
  * @param function $userFunc function ($fName) { ... }
  * @access static
  */
 function processDir($root, $userFunc)
 {
     print "Handle {$root} ...\n";
     if (!chdir($root)) {
         print "Cant't change dir\n";
     }
     $files = dir($root);
     if (!$files) {
         return "Can't read directory {$root}.\n";
     }
     while (($f = $files->read()) !== false) {
         if ($f == "." || $f == "..") {
             continue;
         }
         $f = $root . "/" . $f;
         if (is_file($f)) {
             call_user_func($userFunc, $f);
         } else {
             if (is_dir($f)) {
                 FileUtils::processDir($f, $userFunc);
             }
         }
     }
     $files->close();
 }