reactphp / filesystem

Evented filesystem access.
MIT License
135 stars 40 forks source link

Add feature to rename directories #20

Closed seregazhuk closed 6 years ago

seregazhuk commented 6 years ago

This PR extends DirectoryInterface and adds method to rename() current directory object. The api is the same as FileInterface has:

$loop = Factory::create();
$filesystem = Filesystem::create($loop);
$dir = $filesystem->dir('new');

$dir->rename('new_name')->then(function(\React\Filesystem\Node\DirectoryInterface $newDir){
    echo 'Renamed to ' . $newDir->getPath() . PHP_EOL;
}, function(Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
});