Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Libuv Adapter #69

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ cache:
- $HOME/.composer/cache/files

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

matrix:
allow_failures:
- php: 5.4
- php: 7.1
- php: nightly

install:
- ./travis-init.sh
Expand Down
354 changes: 233 additions & 121 deletions composer.lock

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions src/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use RuntimeException;
use React\EventLoop\LoopInterface;
use React\EventLoop\ExtUvLoop;
use React\Filesystem\Node;

class Filesystem implements FilesystemInterface
Expand All @@ -23,8 +24,12 @@ public static function create(LoopInterface $loop, array $options = [])
{
$adapters = static::getSupportedAdapters();

if (!empty($adapters)) {
$adapter = "\\React\\Filesystem\\".$adapters[0]."\\Adapter";
foreach($adapters as $adapter) {
if($adapter === 'Uv' && !$loop instanceof ExtUvLoop) {
continue;
}

$adapter = "\\React\\Filesystem\\".$adapter."\\Adapter";
return static::setFilesystemOnAdapter(static::createFromAdapter(new $adapter($loop, $options)));
}

Expand Down Expand Up @@ -57,6 +62,10 @@ public static function getSupportedAdapters()
{
$adapters = [];

if (Uv\Adapter::isSupported()) {
$adapters[] = 'Uv';
}

if (Eio\Adapter::isSupported()) {
$adapters[] = 'Eio';
}
Expand Down
4 changes: 4 additions & 0 deletions src/ModeTypeDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function __construct(FilesystemInterface $filesystem)
*/
public function detect(array $node)
{
if (isset($node['mode'])) {
return $this->walkMapping($node);
}

return $this->filesystem->getAdapter()->stat($node['path'])->then(function ($stat) {
return $this->walkMapping($stat);
});
Expand Down
Loading