facebook/hhvm — pull request #1474 by dgiagio (2014-01-01 21:20:58+00:00)
Title: Adds support for some stream_wrappers functions such as mkdir/rmdir/unlink/rename required by Drupal 7

According to some users, Drupal 7 uses public:// and temporary:// to store and move files around by using stream_wrappers. Some functions of stream_wrappers weren't implemented. This patch adds the following missing functions:

- unlink
- rename
- mkdir (recursive or not)
- rmdir

The patch tries to follow the coding style as close as possible. The new functionality can be tested with the following testcase:

```php
$newname"); return true; }
}

// Active assert
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_WARNING, 1);
assert_options(ASSERT_QUIET_EVAL, 0);

# Stream Wrapper tests
stream_wrapper_register("foo", "myStreamWrapper");
assert(mkdir("foo://dir1/dir2", 0644, true));
assert(rmdir("foo://dir1/dir2"));
assert(unlink("foo://dir1/file"));
assert(rename("foo://dir1/file", "foo://dir1/file2"));

# Filesystem tests
assert(mkdir("/tmp/dir1/dir2", 0755, true));
assert(!rmdir("/tmp/dir1"));
assert(rmdir("/tmp/dir1/dir2"));
assert(!unlink("/tmp/dir1/inexistent"));
assert(touch("/tmp/dir1/file"));
assert(rename("/tmp/dir1/file", "/tmp/dir1/file2"));
assert(unlink("/tmp/dir1/file2"));
assert(rmdir("/tmp/dir1"));
?>
```