Class: atkDirectoryTraverser
Source Location: /utils/class.atkdirectorytraverser.inc
Class atkDirectoryTraverser
Class Overview
|
This class can be used to recursively traverse a directory structure.
For each dir or file encountered, it calls callback methods on callbackobjects. This is similar to the unix 'find' command with an execute option. You pass a callbackobject that performs the actual action. The full pathname of the file is passed as a parameter to the callback method.
Located in /utils/class.atkdirectorytraverser.inc [line 33]
Wiki documentation
Author(s):
Information Tags:
|
Properties
|
Methods
|
Method Summary
| void |
addExclude() |
Add a regex expression to prevent detection of certain files/directories |
| void |
isExcluded() |
Check whether a file is excluded or not |
| void |
_callback() |
Perform a callback on all callbackobjects. |
Methods
atkDirectoryTraverser atkDirectoryTraverser(
)
|
|
Constructor
void addCallbackObject(
&$callbackObject, Object
$callbackObject
)
|
|
Add a callback object.
The object can be any object. If the object implements a method with the following signature: function visitDir($fullpath) the method is called for each directory that is traversed. It is also possible to implement a callback method with this signature: function visitFile($fullpath) This method will be called for each regular file. Both methods are optional. If an object does not implement either of these methods, it will simply be ignored.
Parameters:
|
Object |
$callbackObject: |
An object instance to be called back for each file/dir. |
|
|
&$callbackObject: |
|
void addExclude(
string
$regex
)
|
|
Add a regex expression to prevent detection of certain files/directories
Parameters:
void clearCallbackObjects(
)
|
|
Remove all callback objects.
API Tags:
Clear the excluding regex expressions
array getDirContents(
String
$path
)
|
|
Read all the entries of a directory.
Parameters:
|
String |
$path: |
The path to read the contents from. |
API Tags:
| Return: | Array containing the contents of the directory. |
void isExcluded(
string
$file
)
|
|
Check whether a file is excluded or not
Parameters:
boolean traverse(
String
$path
)
|
|
Traverse a path.
This method recursively traverses the specified path. Make sure you pass the path without trailing '/'.
Parameters:
|
String |
$path: |
The path to traverse |
API Tags:
| Return: | true if succesful, false if the path does not exist or is not readable. |
void _callback(
String
$method, String
$filename
)
|
|
Perform a callback on all callbackobjects.
Parameters:
|
String |
$method: |
The name of the method to call. |
|
String |
$filename: |
The filename that will be passed as parameter to the callback. |
API Tags: