thekid/rfc — Issue #77: RFC 0077: I/O Collections Extensions
Author: thekid
Created: 2011-10-09 14:54:38+00:00
State: open
Labels: rfc

Scope of Change
====
New filters will be added to io.collections.iterate.

Rationale
====
Provide filter implementations for most common usecases.

Functionality
====

New IterationFilter implementations
----
Date-based:

```
io.collections.iterate.AccessedAfterFilter
io.collections.iterate.AccessedBeforeFilter
io.collections.iterate.CreatedAfterFilter
io.collections.iterate.CreatedBeforeFilter
io.collections.iterate.ModifiedAfterFilter
io.collections.iterate.ModifiedBeforeFilter

```
Name-based:

```
io.collections.iterate.NameMatchesFilter
io.collections.iterate.NameEqualsFilter
io.collections.iterate.ExtensionEqualsFilter

```
Size-based:

```
io.collections.iterate.SizeBiggerThanFilter
io.collections.iterate.SizeEqualsFilter
io.collections.iterate.SizeSmallerThanFilter

```
Combinations:

```
io.collections.iterate.NegationOfFilter
io.collections.iterate.AllOfFilter
io.collections.iterate.AnyOfFilter

```

IOElement interface changes
----
Access to an IOElement's size, creation, last modified and last
accessed dates will be added to the IOElement interface.

```php

```

Examples
----
Find all JPEG images that have been modified before Dec 14, 2004:

```php

```

Find all files that either end with ".txt" or are smaller than 500 bytes:

```php

```

Print a list of all logfiles modified at least one hour ago, but exclude
errorlogs:

```php
value(1));
$before= &DateUtil::addHours(Date::now(), -1);

Console::writeLine('Working on ', $collection->toString(), ' for ', $before->toString());

for (
$it= &new FilteredIOCollectionIterator($collection, new AllOfFilter(array(
new ModifiedBeforeFilter($before),
new ExtensionEqualsFilter('log'),
new NegationOfFilter(new NameMatchesFilter('/^error/'))
)));
$it->hasNext();
) {
$e= &$it->next();
$file= &new File($e->getURI());

Console::writeLine('- ', xp::stringOf($file));
}
?>
```

Security considerations
====
n/a

Speed impact
====
n/a

Dependencies
====
- io.collections.IOElement additional methods:
getSize(), createdAt(), lastAccessed(), lastModified()

Related documents
====
- xp-framework/rfc #75
Original I/O Collections RFC

- http://xp-framework.net/rfc/contrib/rfc0077.diff
Patch

- http://experiments.xp-framework.net/?people,friebe,fql
Filesystem Query Language - utilizes this patch

Comments
====