Development

Changeset 8391

You must first sign up to be able to contribute.

Changeset 8391

Show
Ignore:
Timestamp:
04/10/08 16:36:24 (1 year ago)
Author:
fabien
Message:

refactored sfFinder::in()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/util/sfFinder.class.php

    r8254 r8391  
    332332    $files    = array(); 
    333333    $here_dir = getcwd(); 
     334 
     335    $finder = clone $this; 
     336 
     337    if ($this->ignore_version_control) 
     338    { 
     339      $ignores = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'); 
     340 
     341      $finder->discard($ignores)->prune($ignores); 
     342    } 
     343 
     344    // first argument is an array? 
    334345    $numargs  = func_num_args(); 
    335346    $arg_list = func_get_args(); 
    336  
    337     $finder = clone $this; 
    338  
    339     if ($this->ignore_version_control) 
    340     { 
    341       $ignores = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'); 
    342  
    343       $finder->discard($ignores)->prune($ignores); 
    344     } 
    345  
    346     // first argument is an array? 
    347347    if ($numargs == 1 && is_array($arg_list[0])) 
    348348    { 
     
    353353    for ($i = 0; $i < $numargs; $i++) 
    354354    { 
    355       $real_dir = realpath($arg_list[$i]); 
     355      $dir = realpath($arg_list[$i]); 
     356 
     357      if (!is_dir($dir)) 
     358      { 
     359        continue; 
     360      } 
     361 
     362      $dir = str_replace('\\', '/', $dir); 
    356363 
    357364      // absolute path? 
    358       if (!self::isPathAbsolute($real_dir)) 
    359       { 
    360         $dir = $here_dir.DIRECTORY_SEPARATOR.$real_dir; 
    361       } 
    362       else 
    363       { 
    364         $dir = $real_dir; 
    365       } 
    366  
    367       if (!is_dir($real_dir)) 
    368       { 
    369         continue; 
    370       } 
    371  
    372       $dir = str_replace(array('/', '\\'), '/', $dir); 
     365      if (!self::isPathAbsolute($dir)) 
     366      { 
     367        $dir = $here_dir.'/'.$dir; 
     368      } 
     369 
     370      $new_files = str_replace('\\', '/', $finder->search_in($dir)); 
    373371 
    374372      if ($this->relative) 
    375373      { 
    376         $dir   = rtrim($dir, '/'); 
    377         $files = array_merge($files, str_replace($dir.'/', '', str_replace(array('/', '\\'), '/', $finder->search_in($dir)))); 
    378       } 
    379       else 
    380       { 
    381         $files = array_merge($files, $finder->search_in($dir)); 
    382       } 
     374        $new_files = str_replace(rtrim($dir, '/').'/', '', $new_files); 
     375      } 
     376 
     377      $files = array_merge($files, $new_files); 
    383378    } 
    384379 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.