1
0
mirror of https://github.com/danog/file.git synced 2024-12-04 02:07:46 +01:00
file/lib/functions.php

25 lines
730 B
PHP
Raw Normal View History

2015-07-11 03:59:39 +02:00
<?php
namespace Amp\Fs;
/**
* Get the global default filesystem instance
*
* @param \Amp\Fs\Filesystem $assign Optionally specify a new default filesystem instance
* @return \Amp\Fs\Filesystem Returns the default filesystem instance
*/
2015-07-17 16:27:38 +02:00
function fs(Filesystem $assign = null) {
2015-07-11 03:59:39 +02:00
static $filesystem;
if ($assign) {
return ($filesystem = $assign);
} elseif ($filesystem) {
return $filesystem;
2015-07-17 16:27:38 +02:00
} elseif (\extension_loaded("uv")) {
return ($filesystem = new UvFilesystem(\Amp\reactor()));
2015-07-18 18:08:50 +02:00
} elseif (\extension_loaded("eio")) {
return ($filesystem = new EioFilesystem(\Amp\reactor()));
2015-07-11 03:59:39 +02:00
} else {
2015-07-17 16:27:38 +02:00
return ($filesystem = new BlockingFilesystem(\Amp\reactor()));
2015-07-11 03:59:39 +02:00
}
}