[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/util/ -> sfFinder.class.php (sommaire)

(pas de description)

Author: Fabien Potencier <fabien.potencier@symfony-project.com>
Version: SVN: $Id: sfFinder.class.php 3268 2007-01-13 20:19:33Z fabien $
Poids: 723 lignes (17 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 3 classes

sfFinder:: (23 méthodes):
  maxdepth()
  mindepth()
  get_type()
  type()
  to_regex()
  args_to_array()
  name()
  not_name()
  size()
  prune()
  discard()
  ignore_version_control()
  exec()
  relative()
  follow_link()
  in()
  search_in()
  match_names()
  size_ok()
  is_pruned()
  is_discarded()
  exec_ok()
  isPathAbsolute()

sfGlobToRegex:: (3 méthodes):
  setStrictLeadingDot()
  setStrictWildcardSlash()
  glob_to_regex()

sfNumberCompare:: (2 méthodes):
  __construct()
  test()


Classe: sfFinder  - X-Ref

Allow to build rules to find files and directories.

All rules may be invoked several times, except for ->in() method.
Some rules are cumulative (->name() for example) whereas others are destructive
(most recent value is used, ->maxdepth() method for example).

All methods return the current sfFinder object to allow easy chaining:

$files = sfFinder::type('file')->name('*.php')->in(.);

Interface loosely based on perl File::Find::Rule module.

maxdepth($level)   X-Ref
Sets maximum directory depth.

Finder will descend at most $level levels of directories below the starting point.

param: integer level
return: object current sfFinder object

mindepth($level)   X-Ref
Sets minimum directory depth.

Finder will start applying tests at level $level.

param: integer level
return: object current sfFinder object

get_type()   X-Ref
Pas de description

type($name)   X-Ref
Sets the type of elements to returns.

param: string directory or file or any (for both file and directory)
return: object new sfFinder object

to_regex($str)   X-Ref
Pas de description

args_to_array($arg_list, $not = false)   X-Ref
Pas de description

name()   X-Ref
Adds rules that files must match.

You can use patterns (delimited with / sign), globs or simple strings.

$finder->name('*.php')
$finder->name('/\.php$/') // same as above
$finder->name('test.php')

param: list   a list of patterns, globs or strings
return: object current sfFinder object

not_name()   X-Ref
Adds rules that files must not match.

param: list   a list of patterns, globs or strings
return: object current sfFinder object

size()   X-Ref
Adds tests for file sizes.

$finder->size('> 10K');
$finder->size('<= 1Ki');
$finder->size(4);

param: list   a list of comparison strings
return: object current sfFinder object

prune()   X-Ref
Traverses no further.

param: list   a list of patterns, globs to match
return: object current sfFinder object

discard()   X-Ref
Discards elements that matches.

param: list   a list of patterns, globs to match
return: object current sfFinder object

ignore_version_control()   X-Ref
Ignores version control directories.

Currently supports subversion, CVS, DARCS, Gnu Arch, Monotone, Bazaar-NG

return: object current pakeFinder object

exec()   X-Ref
Executes function or method for each element.

Element match if functino or method returns true.

$finder->exec('myfunction');
$finder->exec(array($object, 'mymethod'));

param: mixed  function or method to call
return: object current sfFinder object

relative()   X-Ref
Returns relative paths for all files and directories.

return: object current sfFinder object

follow_link()   X-Ref
Symlink following.

return: object current sfFinder object

in()   X-Ref
Searches files and directories which match defined rules.

return: array list of files and directories

search_in($dir, $depth = 0)   X-Ref
Pas de description

match_names($dir, $entry)   X-Ref
Pas de description

size_ok($dir, $entry)   X-Ref
Pas de description

is_pruned($dir, $entry)   X-Ref
Pas de description

is_discarded($dir, $entry)   X-Ref
Pas de description

exec_ok($dir, $entry)   X-Ref
Pas de description

isPathAbsolute($path)   X-Ref
Pas de description

Classe: sfGlobToRegex  - X-Ref

Match globbing patterns against text.

if match_glob("foo.*", "foo.bar") echo "matched\n";

// prints foo.bar and foo.baz
$regex = glob_to_regex("foo.*");
for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t)
{
if (/$regex/) echo "matched: $car\n";
}

sfGlobToRegex implements glob(3) style matching that can be used to match
against text, rather than fetching names from a filesystem.

based on perl Text::Glob module.

setStrictLeadingDot($boolean)   X-Ref
Pas de description

setStrictWildcardSlash($boolean)   X-Ref
Pas de description

glob_to_regex($glob)   X-Ref
Returns a compiled regex which is the equiavlent of the globbing pattern.

param: string glob pattern
return: string regex

Classe: sfNumberCompare  - X-Ref

Numeric comparisons.

sfNumberCompare compiles a simple comparison to an anonymous
subroutine, which you can call with a value to be tested again.
Now this would be very pointless, if sfNumberCompare didn't understand
magnitudes.
The target value may use magnitudes of kilobytes (k, ki),
megabytes (m, mi), or gigabytes (g, gi).  Those suffixed
with an i use the appropriate 2**n version in accordance with the
IEC standard: http://physics.nist.gov/cuu/Units/binary.html

based on perl Number::Compare module.

__construct($test)   X-Ref
Pas de description

test($number)   X-Ref
Pas de description



Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7