zendframework/ZendSearch — pull request #7 by mburtscher (2013-07-26 12:56:58+00:00)
Title: Keep only one file handle open

This pull request fixes issue #6: Only one file handle should be kept open at a time. Only the ```Filesystem``` class has been touched.

# Description

The Filesystem object with an open file handle is always stored in the static field ```Filesystem::$openFile```. If a new file handle is created, the currently active one will be closed. Before each file operation the handle is opened again and seeked to the previous position.

This also allows operations like this to perform well because file handle is not closed until a new one is created:

```php
$file = new Filesystem("test.txt");
$file->lock(),
$file->write("a");
$file->write("b");
$file->write("c");
$file->unlock();
$file->close();
```

# Example

```php
$file1 = new Filesystem("file1.txt");
$file2 = new Filesystem("file2.txt");
$file1->lock(); // File handle for file1.txt is opened
$file1->write("a");
$file2->write("b"); // File handle for file1.txt is closed, file handle for file2.txt is opened
$file1->unlock(); // File handle for file2.txt is closed, file handle for file1.txt is opened
$file1->close(); // File handle for file1.txt is closed
$file2->close();