update for version 1.0.1
This commit is contained in:
157
code/vendor/laravel/framework/src/Illuminate/Filesystem/ClassFinder.php
vendored
Normal file
157
code/vendor/laravel/framework/src/Illuminate/Filesystem/ClassFinder.php
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php namespace Illuminate\Filesystem;
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class ClassFinder {
|
||||
|
||||
/**
|
||||
* Find all the class and interface names in a given directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return array
|
||||
*/
|
||||
public function findClasses($directory)
|
||||
{
|
||||
$classes = [];
|
||||
|
||||
foreach (Finder::create()->in($directory)->name('*.php') as $file)
|
||||
{
|
||||
$classes[] = $this->findClass($file->getRealPath());
|
||||
}
|
||||
|
||||
return array_filter($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the class name from the file at the given path.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string|null
|
||||
*/
|
||||
public function findClass($path)
|
||||
{
|
||||
$namespace = null;
|
||||
|
||||
$tokens = token_get_all(file_get_contents($path));
|
||||
|
||||
foreach ($tokens as $key => $token)
|
||||
{
|
||||
if ($this->tokenIsNamespace($token))
|
||||
{
|
||||
$namespace = $this->getNamespace($key + 2, $tokens);
|
||||
}
|
||||
elseif ($this->tokenIsClassOrInterface($token))
|
||||
{
|
||||
return ltrim($namespace.'\\'.$this->getClass($key + 2, $tokens), '\\');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the namespace in the tokens starting at a given key.
|
||||
*
|
||||
* @param int $key
|
||||
* @param array $tokens
|
||||
* @return string
|
||||
*/
|
||||
protected function getNamespace($key, array $tokens)
|
||||
{
|
||||
$namespace = null;
|
||||
|
||||
$tokenCount = count($tokens);
|
||||
|
||||
for ($i = $key; $i < $tokenCount; $i++)
|
||||
{
|
||||
if ($this->isPartOfNamespace($tokens[$i]))
|
||||
{
|
||||
$namespace .= $tokens[$i][1];
|
||||
}
|
||||
elseif ($tokens[$i] == ';')
|
||||
{
|
||||
return $namespace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the class in the tokens starting at a given key.
|
||||
*
|
||||
* @param int $key
|
||||
* @param array $tokens
|
||||
* @return string
|
||||
*/
|
||||
protected function getClass($key, array $tokens)
|
||||
{
|
||||
$class = null;
|
||||
|
||||
$tokenCount = count($tokens);
|
||||
|
||||
for ($i = $key; $i < $tokenCount; $i++)
|
||||
{
|
||||
if ($this->isPartOfClass($tokens[$i]))
|
||||
{
|
||||
$class .= $tokens[$i][1];
|
||||
}
|
||||
elseif ($this->isWhitespace($tokens[$i]))
|
||||
{
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given token is a namespace keyword.
|
||||
*
|
||||
* @param array|string $token
|
||||
* @return bool
|
||||
*/
|
||||
protected function tokenIsNamespace($token)
|
||||
{
|
||||
return is_array($token) && $token[0] == T_NAMESPACE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given token is a class or interface keyword.
|
||||
*
|
||||
* @param array|string $token
|
||||
* @return bool
|
||||
*/
|
||||
protected function tokenIsClassOrInterface($token)
|
||||
{
|
||||
return is_array($token) && ($token[0] == T_CLASS || $token[0] == T_INTERFACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given token is part of the namespace.
|
||||
*
|
||||
* @param array|string $token
|
||||
* @return bool
|
||||
*/
|
||||
protected function isPartOfNamespace($token)
|
||||
{
|
||||
return is_array($token) && ($token[0] == T_STRING || $token[0] == T_NS_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given token is part of the class.
|
||||
*
|
||||
* @param array|string $token
|
||||
* @return bool
|
||||
*/
|
||||
protected function isPartOfClass($token)
|
||||
{
|
||||
return is_array($token) && $token[0] == T_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given token is whitespace.
|
||||
*
|
||||
* @param array|string $token
|
||||
* @return bool
|
||||
*/
|
||||
protected function isWhitespace($token)
|
||||
{
|
||||
return is_array($token) && $token[0] == T_WHITESPACE;
|
||||
}
|
||||
|
||||
}
|
||||
441
code/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php
vendored
Normal file
441
code/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php
vendored
Normal file
@@ -0,0 +1,441 @@
|
||||
<?php namespace Illuminate\Filesystem;
|
||||
|
||||
use ErrorException;
|
||||
use FilesystemIterator;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
|
||||
class Filesystem {
|
||||
|
||||
use Macroable;
|
||||
|
||||
/**
|
||||
* Determine if a file exists.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($path)
|
||||
{
|
||||
return file_exists($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contents of a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get($path)
|
||||
{
|
||||
if ($this->isFile($path)) return file_get_contents($path);
|
||||
|
||||
throw new FileNotFoundException("File does not exist at path {$path}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the returned value of a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function getRequire($path)
|
||||
{
|
||||
if ($this->isFile($path)) return require $path;
|
||||
|
||||
throw new FileNotFoundException("File does not exist at path {$path}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Require the given file once.
|
||||
*
|
||||
* @param string $file
|
||||
* @return mixed
|
||||
*/
|
||||
public function requireOnce($file)
|
||||
{
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the contents of a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $contents
|
||||
* @param bool $lock
|
||||
* @return int
|
||||
*/
|
||||
public function put($path, $contents, $lock = false)
|
||||
{
|
||||
return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend to a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $data
|
||||
* @return int
|
||||
*/
|
||||
public function prepend($path, $data)
|
||||
{
|
||||
if ($this->exists($path))
|
||||
{
|
||||
return $this->put($path, $data.$this->get($path));
|
||||
}
|
||||
|
||||
return $this->put($path, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append to a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $data
|
||||
* @return int
|
||||
*/
|
||||
public function append($path, $data)
|
||||
{
|
||||
return file_put_contents($path, $data, FILE_APPEND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the file at a given path.
|
||||
*
|
||||
* @param string|array $paths
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($paths)
|
||||
{
|
||||
$paths = is_array($paths) ? $paths : func_get_args();
|
||||
|
||||
$success = true;
|
||||
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( ! @unlink($path))
|
||||
{
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
catch (ErrorException $e)
|
||||
{
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a file to a new location.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $target
|
||||
* @return bool
|
||||
*/
|
||||
public function move($path, $target)
|
||||
{
|
||||
return rename($path, $target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a file to a new location.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $target
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($path, $target)
|
||||
{
|
||||
return copy($path, $target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the file name from a file path.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function name($path)
|
||||
{
|
||||
return pathinfo($path, PATHINFO_FILENAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the file extension from a file path.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function extension($path)
|
||||
{
|
||||
return pathinfo($path, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file type of a given file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function type($path)
|
||||
{
|
||||
return filetype($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mime-type of a given file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string|false
|
||||
*/
|
||||
public function mimeType($path)
|
||||
{
|
||||
return finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file size of a given file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return int
|
||||
*/
|
||||
public function size($path)
|
||||
{
|
||||
return filesize($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's last modification time.
|
||||
*
|
||||
* @param string $path
|
||||
* @return int
|
||||
*/
|
||||
public function lastModified($path)
|
||||
{
|
||||
return filemtime($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given path is a directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return bool
|
||||
*/
|
||||
public function isDirectory($directory)
|
||||
{
|
||||
return is_dir($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given path is writable.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function isWritable($path)
|
||||
{
|
||||
return is_writable($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given path is a file.
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function isFile($file)
|
||||
{
|
||||
return is_file($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find path names matching a given pattern.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param int $flags
|
||||
* @return array
|
||||
*/
|
||||
public function glob($pattern, $flags = 0)
|
||||
{
|
||||
return glob($pattern, $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all files in a directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return array
|
||||
*/
|
||||
public function files($directory)
|
||||
{
|
||||
$glob = glob($directory.'/*');
|
||||
|
||||
if ($glob === false) return array();
|
||||
|
||||
// To get the appropriate files, we'll simply glob the directory and filter
|
||||
// out any "files" that are not truly files so we do not end up with any
|
||||
// directories in our list, but only true files within the directory.
|
||||
return array_filter($glob, function($file)
|
||||
{
|
||||
return filetype($file) == 'file';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the files from the given directory (recursive).
|
||||
*
|
||||
* @param string $directory
|
||||
* @return array
|
||||
*/
|
||||
public function allFiles($directory)
|
||||
{
|
||||
return iterator_to_array(Finder::create()->files()->in($directory), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the directories within a given directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return array
|
||||
*/
|
||||
public function directories($directory)
|
||||
{
|
||||
$directories = array();
|
||||
|
||||
foreach (Finder::create()->in($directory)->directories()->depth(0) as $dir)
|
||||
{
|
||||
$directories[] = $dir->getPathname();
|
||||
}
|
||||
|
||||
return $directories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $mode
|
||||
* @param bool $recursive
|
||||
* @param bool $force
|
||||
* @return bool
|
||||
*/
|
||||
public function makeDirectory($path, $mode = 0755, $recursive = false, $force = false)
|
||||
{
|
||||
if ($force)
|
||||
{
|
||||
return @mkdir($path, $mode, $recursive);
|
||||
}
|
||||
|
||||
return mkdir($path, $mode, $recursive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a directory from one location to another.
|
||||
*
|
||||
* @param string $directory
|
||||
* @param string $destination
|
||||
* @param int $options
|
||||
* @return bool
|
||||
*/
|
||||
public function copyDirectory($directory, $destination, $options = null)
|
||||
{
|
||||
if ( ! $this->isDirectory($directory)) return false;
|
||||
|
||||
$options = $options ?: FilesystemIterator::SKIP_DOTS;
|
||||
|
||||
// If the destination directory does not actually exist, we will go ahead and
|
||||
// create it recursively, which just gets the destination prepared to copy
|
||||
// the files over. Once we make the directory we'll proceed the copying.
|
||||
if ( ! $this->isDirectory($destination))
|
||||
{
|
||||
$this->makeDirectory($destination, 0777, true);
|
||||
}
|
||||
|
||||
$items = new FilesystemIterator($directory, $options);
|
||||
|
||||
foreach ($items as $item)
|
||||
{
|
||||
// As we spin through items, we will check to see if the current file is actually
|
||||
// a directory or a file. When it is actually a directory we will need to call
|
||||
// back into this function recursively to keep copying these nested folders.
|
||||
$target = $destination.'/'.$item->getBasename();
|
||||
|
||||
if ($item->isDir())
|
||||
{
|
||||
$path = $item->getPathname();
|
||||
|
||||
if ( ! $this->copyDirectory($path, $target, $options)) return false;
|
||||
}
|
||||
|
||||
// If the current items is just a regular file, we will just copy this to the new
|
||||
// location and keep looping. If for some reason the copy fails we'll bail out
|
||||
// and return false, so the developer is aware that the copy process failed.
|
||||
else
|
||||
{
|
||||
if ( ! $this->copy($item->getPathname(), $target)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively delete a directory.
|
||||
*
|
||||
* The directory itself may be optionally preserved.
|
||||
*
|
||||
* @param string $directory
|
||||
* @param bool $preserve
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteDirectory($directory, $preserve = false)
|
||||
{
|
||||
if ( ! $this->isDirectory($directory)) return false;
|
||||
|
||||
$items = new FilesystemIterator($directory);
|
||||
|
||||
foreach ($items as $item)
|
||||
{
|
||||
// If the item is a directory, we can just recurse into the function and
|
||||
// delete that sub-directory otherwise we'll just delete the file and
|
||||
// keep iterating through each file until the directory is cleaned.
|
||||
if ($item->isDir() && ! $item->isLink())
|
||||
{
|
||||
$this->deleteDirectory($item->getPathname());
|
||||
}
|
||||
|
||||
// If the item is just a file, we can go ahead and delete it since we're
|
||||
// just looping through and waxing all of the files in this directory
|
||||
// and calling directories recursively, so we delete the real path.
|
||||
else
|
||||
{
|
||||
$this->delete($item->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $preserve) @rmdir($directory);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the specified directory of all files and folders.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return bool
|
||||
*/
|
||||
public function cleanDirectory($directory)
|
||||
{
|
||||
return $this->deleteDirectory($directory, true);
|
||||
}
|
||||
|
||||
}
|
||||
332
code/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php
vendored
Normal file
332
code/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php
vendored
Normal file
@@ -0,0 +1,332 @@
|
||||
<?php namespace Illuminate\Filesystem;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\FilesystemInterface;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract;
|
||||
use Illuminate\Contracts\Filesystem\Cloud as CloudFilesystemContract;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException as ContractFileNotFoundException;
|
||||
|
||||
class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract {
|
||||
|
||||
/**
|
||||
* The Flysystem filesystem implementation.
|
||||
*
|
||||
* @var \League\Flysystem\FilesystemInterface
|
||||
*/
|
||||
protected $driver;
|
||||
|
||||
/**
|
||||
* Create a new filesystem adapter instance.
|
||||
*
|
||||
* @param \League\Flysystem\FilesystemInterface $driver
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(FilesystemInterface $driver)
|
||||
{
|
||||
$this->driver = $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a file exists.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($path)
|
||||
{
|
||||
return $this->driver->has($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contents of a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get($path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->driver->read($path);
|
||||
}
|
||||
catch (FileNotFoundException $e)
|
||||
{
|
||||
throw new ContractFileNotFoundException($path, $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the contents of a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string|resource $contents
|
||||
* @param string $visibility
|
||||
* @return bool
|
||||
*/
|
||||
public function put($path, $contents, $visibility = null)
|
||||
{
|
||||
$config = ['visibility' => $this->parseVisibility($visibility)];
|
||||
|
||||
if (is_resource($contents))
|
||||
{
|
||||
return $this->driver->putStream($path, $contents, $config);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->driver->put($path, $contents, $config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visibility for the given path.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getVisibility($path)
|
||||
{
|
||||
if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC)
|
||||
{
|
||||
return FilesystemContract::VISIBILITY_PUBLIC;
|
||||
}
|
||||
|
||||
return FilesystemContract::VISIBILITY_PRIVATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visibility for the given path.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $visibility
|
||||
* @return void
|
||||
*/
|
||||
public function setVisibility($path, $visibility)
|
||||
{
|
||||
return $this->driver->setVisibility($path, $this->parseVisibility($visibility));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend to a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $data
|
||||
* @return int
|
||||
*/
|
||||
public function prepend($path, $data)
|
||||
{
|
||||
return $this->put($path, $data.PHP_EOL.$this->get($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append to a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $data
|
||||
* @return int
|
||||
*/
|
||||
public function append($path, $data)
|
||||
{
|
||||
return $this->put($path, $this->get($path).PHP_EOL.$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the file at a given path.
|
||||
*
|
||||
* @param string|array $paths
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($paths)
|
||||
{
|
||||
$paths = is_array($paths) ? $paths : func_get_args();
|
||||
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$this->driver->delete($path);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a file to a new location.
|
||||
*
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($from, $to)
|
||||
{
|
||||
return $this->driver->copy($from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a file to a new location.
|
||||
*
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
* @return bool
|
||||
*/
|
||||
public function move($from, $to)
|
||||
{
|
||||
return $this->driver->rename($from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file size of a given file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return int
|
||||
*/
|
||||
public function size($path)
|
||||
{
|
||||
return $this->driver->getSize($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mime-type of a given file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string|false
|
||||
*/
|
||||
public function mimeType($path)
|
||||
{
|
||||
return $this->driver->getMimetype($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's last modification time.
|
||||
*
|
||||
* @param string $path
|
||||
* @return int
|
||||
*/
|
||||
public function lastModified($path)
|
||||
{
|
||||
return $this->driver->getTimestamp($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all files in a directory.
|
||||
*
|
||||
* @param string|null $directory
|
||||
* @param bool $recursive
|
||||
* @return array
|
||||
*/
|
||||
public function files($directory = null, $recursive = false)
|
||||
{
|
||||
$contents = $this->driver->listContents($directory, $recursive);
|
||||
|
||||
return $this->filterContentsByType($contents, 'file');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the files from the given directory (recursive).
|
||||
*
|
||||
* @param string|null $directory
|
||||
* @return array
|
||||
*/
|
||||
public function allFiles($directory = null)
|
||||
{
|
||||
return $this->files($directory, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the directories within a given directory.
|
||||
*
|
||||
* @param string|null $directory
|
||||
* @param bool $recursive
|
||||
* @return array
|
||||
*/
|
||||
public function directories($directory = null, $recursive = false)
|
||||
{
|
||||
$contents = $this->driver->listContents($directory, $recursive);
|
||||
|
||||
return $this->filterContentsByType($contents, 'dir');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all (recursive) of the directories within a given directory.
|
||||
*
|
||||
* @param string|null $directory
|
||||
* @return array
|
||||
*/
|
||||
public function allDirectories($directory = null)
|
||||
{
|
||||
return $this->directories($directory, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function makeDirectory($path)
|
||||
{
|
||||
return $this->driver->createDir($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively delete a directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteDirectory($directory)
|
||||
{
|
||||
return $this->driver->deleteDir($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Flysystem driver.
|
||||
*
|
||||
* @return \League\Flysystem\FilesystemInterface
|
||||
*/
|
||||
public function getDriver()
|
||||
{
|
||||
return $this->driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter directory contents by type.
|
||||
*
|
||||
* @param array $contents
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
protected function filterContentsByType($contents, $type)
|
||||
{
|
||||
return Collection::make($contents)
|
||||
->where('type', $type)
|
||||
->fetch('path')
|
||||
->values()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given visibility value.
|
||||
*
|
||||
* @param string|null $visibility
|
||||
* @return string
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function parseVisibility($visibility)
|
||||
{
|
||||
if (is_null($visibility)) return;
|
||||
|
||||
switch ($visibility)
|
||||
{
|
||||
case FilesystemContract::VISIBILITY_PUBLIC:
|
||||
return AdapterInterface::VISIBILITY_PUBLIC;
|
||||
|
||||
case FilesystemContract::VISIBILITY_PRIVATE:
|
||||
return AdapterInterface::VISIBILITY_PRIVATE;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException('Unknown visibility: '.$visibility);
|
||||
}
|
||||
|
||||
}
|
||||
235
code/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php
vendored
Normal file
235
code/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php namespace Illuminate\Filesystem;
|
||||
|
||||
use Closure;
|
||||
use Aws\S3\S3Client;
|
||||
use OpenCloud\Rackspace;
|
||||
use League\Flysystem\FilesystemInterface;
|
||||
use League\Flysystem\Filesystem as Flysystem;
|
||||
use League\Flysystem\Rackspace\RackspaceAdapter;
|
||||
use League\Flysystem\Adapter\Local as LocalAdapter;
|
||||
use League\Flysystem\AwsS3v2\AwsS3Adapter as S3Adapter;
|
||||
use Illuminate\Contracts\Filesystem\Factory as FactoryContract;
|
||||
|
||||
class FilesystemManager implements FactoryContract {
|
||||
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The array of resolved filesystem drivers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $disks = [];
|
||||
|
||||
/**
|
||||
* The registered custom driver creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customCreators = [];
|
||||
|
||||
/**
|
||||
* Create a new filesystem manager instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a filesystem instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
public function drive($name = null)
|
||||
{
|
||||
return $this->disk($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a filesystem instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
public function disk($name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
return $this->disks[$name] = $this->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the disk from the local cache.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
protected function get($name)
|
||||
{
|
||||
return isset($this->disks[$name]) ? $this->disks[$name] : $this->resolve($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given disk.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
protected function resolve($name)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (isset($this->customCreators[$config['driver']]))
|
||||
{
|
||||
return $this->callCustomCreator($config);
|
||||
}
|
||||
|
||||
return $this->{"create".ucfirst($config['driver'])."Driver"}($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a custom driver creator.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
protected function callCustomCreator(array $config)
|
||||
{
|
||||
$driver = $this->customCreators[$config['driver']]($this->app, $config);
|
||||
|
||||
if ($driver instanceof FilesystemInterface)
|
||||
{
|
||||
return $this->adapt($driver);
|
||||
}
|
||||
|
||||
return $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the local driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
public function createLocalDriver(array $config)
|
||||
{
|
||||
return $this->adapt(new Flysystem(new LocalAdapter($config['root'])));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Amazon S3 driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Filesystem\Cloud
|
||||
*/
|
||||
public function createS3Driver(array $config)
|
||||
{
|
||||
$s3Config = array_only($config, ['key', 'region', 'secret', 'signature', 'base_url']);
|
||||
|
||||
return $this->adapt(
|
||||
new Flysystem(new S3Adapter(S3Client::factory($s3Config), $config['bucket']))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Rackspace driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Filesystem\Cloud
|
||||
*/
|
||||
public function createRackspaceDriver(array $config)
|
||||
{
|
||||
$client = new Rackspace($config['endpoint'], [
|
||||
'username' => $config['username'], 'apiKey' => $config['key'],
|
||||
]);
|
||||
|
||||
return $this->adapt(new Flysystem(
|
||||
new RackspaceAdapter($this->getRackspaceContainer($client, $config))
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Rackspace Cloud Files container.
|
||||
*
|
||||
* @param Rackspace $client
|
||||
* @param array $config
|
||||
* @return \OpenCloud\ObjectStore\Resource\Container
|
||||
*/
|
||||
protected function getRackspaceContainer(Rackspace $client, array $config)
|
||||
{
|
||||
$urlType = array_get($config, 'url_type');
|
||||
|
||||
$store = $client->objectStoreService('cloudFiles', $config['region'], $urlType);
|
||||
|
||||
return $store->getContainer($config['container']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt the filesystem implementation.
|
||||
*
|
||||
* @param \League\Flysystem\FilesystemInterface $filesystem
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
protected function adapt(FilesystemInterface $filesystem)
|
||||
{
|
||||
return new FilesystemAdapter($filesystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filesystem connection configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
return $this->app['config']["filesystems.disks.{$name}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default driver name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['filesystems.default'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function extend($driver, Closure $callback)
|
||||
{
|
||||
$this->customCreators[$driver] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return call_user_func_array(array($this->disk(), $method), $parameters);
|
||||
}
|
||||
|
||||
}
|
||||
82
code/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemServiceProvider.php
vendored
Normal file
82
code/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemServiceProvider.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php namespace Illuminate\Filesystem;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class FilesystemServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->registerNativeFilesystem();
|
||||
|
||||
$this->registerFlysystem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the native filesystem implementation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerNativeFilesystem()
|
||||
{
|
||||
$this->app->singleton('files', function() { return new Filesystem; });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the driver based filesystem.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerFlysystem()
|
||||
{
|
||||
$this->registerManager();
|
||||
|
||||
$this->app->singleton('filesystem.disk', function()
|
||||
{
|
||||
return $this->app['filesystem']->disk($this->getDefaultDriver());
|
||||
});
|
||||
|
||||
$this->app->singleton('filesystem.cloud', function()
|
||||
{
|
||||
return $this->app['filesystem']->disk($this->getCloudDriver());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the filesystem manager.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerManager()
|
||||
{
|
||||
$this->app->singleton('filesystem', function()
|
||||
{
|
||||
return new FilesystemManager($this->app);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default file driver.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['filesystems.default'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default cloud based file driver.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getCloudDriver()
|
||||
{
|
||||
return $this->app['config']['filesystems.cloud'];
|
||||
}
|
||||
|
||||
}
|
||||
38
code/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json
vendored
Normal file
38
code/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "illuminate/filesystem",
|
||||
"description": "The Illuminate Filesystem package.",
|
||||
"license": "MIT",
|
||||
"homepage": "http://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"illuminate/support": "5.0.*",
|
||||
"symfony/finder": "2.6.*",
|
||||
"league/flysystem": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Filesystem\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"league/flysystem-aws-s3-v2": "Required to use the Flysystem S3 driver (~1.0).",
|
||||
"league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0)."
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
Reference in New Issue
Block a user