package and depencies
This commit is contained in:
1
vendor/league/flysystem/.dockerignore
vendored
Normal file
1
vendor/league/flysystem/.dockerignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.git
|
||||
76
vendor/league/flysystem/CODE_OF_CONDUCT.md
vendored
76
vendor/league/flysystem/CODE_OF_CONDUCT.md
vendored
@@ -1,76 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at info+flysystem@frankdejonge.nl. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
2
vendor/league/flysystem/INFO.md
vendored
Normal file
2
vendor/league/flysystem/INFO.md
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
View the docs at: https://flysystem.thephpleague.com/docs/
|
||||
Changelog at: https://github.com/thephpleague/flysystem/blob/3.x/CHANGELOG.md
|
||||
2
vendor/league/flysystem/LICENSE
vendored
2
vendor/league/flysystem/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013-2019 Frank de Jonge
|
||||
Copyright (c) 2013-2023 Frank de Jonge
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
16
vendor/league/flysystem/SECURITY.md
vendored
16
vendor/league/flysystem/SECURITY.md
vendored
@@ -1,16 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.0.x | :white_check_mark: |
|
||||
| 2.0.x | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
When you've encountered a security vulnerability, please disclose it securely.
|
||||
|
||||
The security process is described at:
|
||||
[https://flysystem.thephpleague.com/docs/security/](https://flysystem.thephpleague.com/docs/security/)
|
||||
|
||||
99
vendor/league/flysystem/composer.json
vendored
99
vendor/league/flysystem/composer.json
vendored
@@ -1,68 +1,53 @@
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
"type": "library",
|
||||
"description": "Filesystem abstraction: Many filesystems, one API.",
|
||||
"description": "File storage abstraction for PHP",
|
||||
"keywords": [
|
||||
"filesystem", "filesystems", "files", "storage", "dropbox", "aws",
|
||||
"abstraction", "s3", "ftp", "sftp", "remote", "webdav",
|
||||
"file systems", "cloud", "cloud files", "rackspace", "copy.com"
|
||||
"filesystem", "filesystems", "files", "storage", "aws",
|
||||
"s3", "ftp", "sftp", "webdav", "file", "cloud"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"type": "other",
|
||||
"url": "https://offset.earth/frankdejonge"
|
||||
"scripts": {
|
||||
"phpstan": "vendor/bin/phpstan analyse -l 6 src"
|
||||
},
|
||||
"type": "library",
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"League\\Flysystem\\": "src"
|
||||
}
|
||||
],
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.0.2",
|
||||
"league/mime-type-detection": "^1.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-zip": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-ftp": "*",
|
||||
"microsoft/azure-storage-blob": "^1.1",
|
||||
"phpunit/phpunit": "^9.5.11",
|
||||
"phpstan/phpstan": "^0.12.26",
|
||||
"phpseclib/phpseclib": "^3.0.14",
|
||||
"aws/aws-sdk-php": "^3.220.0",
|
||||
"composer/semver": "^3.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.5",
|
||||
"google/cloud-storage": "^1.23",
|
||||
"async-aws/s3": "^1.5",
|
||||
"async-aws/simple-s3": "^1.1",
|
||||
"sabre/dav": "^4.3.1"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/http-client": "<5.2",
|
||||
"guzzlehttp/ringphp": "<1.1.1",
|
||||
"guzzlehttp/guzzle": "<7.0",
|
||||
"aws/aws-sdk-php": "3.209.31 || 3.210.0",
|
||||
"phpseclib/phpseclib": "3.0.15"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Frank de Jonge",
|
||||
"email": "info@frenky.net"
|
||||
"email": "info@frankdejonge.nl"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"ext-fileinfo": "*",
|
||||
"league/mime-type-detection": "^1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/prophecy": "^1.11.1",
|
||||
"phpunit/phpunit": "^8.5.8"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"League\\Flysystem\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"League\\Flysystem\\Stub\\": "stub/"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
|
||||
"league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
|
||||
"league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
|
||||
"league/flysystem-webdav": "Allows you to use WebDAV storage",
|
||||
"league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2",
|
||||
"league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3",
|
||||
"spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
|
||||
"srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications",
|
||||
"league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching",
|
||||
"ext-ftp": "Allows you to use FTP server storage",
|
||||
"ext-openssl": "Allows you to use FTPS server storage",
|
||||
"league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib",
|
||||
"league/flysystem-ziparchive": "Allows you to use ZipArchive adapter"
|
||||
},
|
||||
"conflict": {
|
||||
"league/flysystem-sftp": "<1.0.6"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"phpstan": "php phpstan.php"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
19
vendor/league/flysystem/deprecations.md
vendored
19
vendor/league/flysystem/deprecations.md
vendored
@@ -1,19 +0,0 @@
|
||||
# Deprecations
|
||||
|
||||
This document lists all the planned deprecations.
|
||||
|
||||
## Handlers will be removed in 2.0
|
||||
|
||||
The `Handler` type and associated calls will be removed in version 2.0.
|
||||
|
||||
### Upgrade path
|
||||
|
||||
You should create your own implementation for handling OOP usage,
|
||||
but it's recommended to move away from using an OOP-style wrapper entirely.
|
||||
|
||||
The reason for this is that it's too easy for implementation details (for
|
||||
your application this is Flysystem) to leak into the application. The most
|
||||
important part for Flysystem is that it improves portability and creates a
|
||||
solid boundary between your application core and the infrastructure you use.
|
||||
The OOP-style handling breaks this principle, therefore I want to stop
|
||||
promoting it.
|
||||
77
vendor/league/flysystem/docker-compose.yml
vendored
Normal file
77
vendor/league/flysystem/docker-compose.yml
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
---
|
||||
version: "3"
|
||||
services:
|
||||
sabredav:
|
||||
image: php:8.1-alpine3.15
|
||||
restart: always
|
||||
volumes:
|
||||
- ./:/var/www/html/
|
||||
ports:
|
||||
- "4040:4040"
|
||||
command: php -S 0.0.0.0:4040 /var/www/html/src/WebDAV/resources/server.php
|
||||
webdav:
|
||||
image: bytemark/webdav
|
||||
restart: always
|
||||
ports:
|
||||
- "4080:80"
|
||||
environment:
|
||||
AUTH_TYPE: Digest
|
||||
USERNAME: alice
|
||||
PASSWORD: secret1234
|
||||
ANONYMOUS_METHODS: 'GET,OPTIONS'
|
||||
sftp:
|
||||
container_name: sftp
|
||||
restart: always
|
||||
image: atmoz/sftp
|
||||
volumes:
|
||||
- ./test_files/sftp/users.conf:/etc/sftp/users.conf
|
||||
- ./test_files/sftp/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key
|
||||
- ./test_files/sftp/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key
|
||||
- ./test_files/sftp/id_rsa.pub:/home/bar/.ssh/keys/id_rsa.pub
|
||||
ports:
|
||||
- "2222:22"
|
||||
sftp_eddsa_only:
|
||||
container_name: sftp_eddsa_only
|
||||
restart: always
|
||||
image: atmoz/sftp
|
||||
volumes:
|
||||
- ./test_files/sftp/users.conf:/etc/sftp/users.conf
|
||||
- ./test_files/sftp/sshd_custom_configs.sh:/etc/sftp.d/sshd_custom_configs.sh
|
||||
- ./test_files/sftp/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key
|
||||
ports:
|
||||
- "2223:22"
|
||||
ftp:
|
||||
container_name: ftp
|
||||
restart: always
|
||||
image: delfer/alpine-ftp-server
|
||||
environment:
|
||||
USERS: 'foo|pass|/home/foo/upload'
|
||||
ADDRESS: 'localhost'
|
||||
ports:
|
||||
- "2121:21"
|
||||
- "21000-21010:21000-21010"
|
||||
ftpd:
|
||||
container_name: ftpd
|
||||
restart: always
|
||||
environment:
|
||||
PUBLICHOST: localhost
|
||||
FTP_USER_NAME: foo
|
||||
FTP_USER_PASS: pass
|
||||
FTP_USER_HOME: /home/foo
|
||||
image: stilliard/pure-ftpd
|
||||
ports:
|
||||
- "2122:21"
|
||||
- "30000-30009:30000-30009"
|
||||
command: "/run.sh -l puredb:/etc/pure-ftpd/pureftpd.pdb -E -j -P localhost"
|
||||
toxiproxy:
|
||||
container_name: toxiproxy
|
||||
restart: unless-stopped
|
||||
image: ghcr.io/shopify/toxiproxy
|
||||
command: "-host 0.0.0.0 -config /opt/toxiproxy/config.json"
|
||||
volumes:
|
||||
- ./test_files/toxiproxy/toxiproxy.json:/opt/toxiproxy/config.json:ro
|
||||
ports:
|
||||
- "8474:8474" # HTTP API
|
||||
- "8222:8222" # SFTP
|
||||
- "8121:8121" # FTP
|
||||
- "8122:8122" # FTPD
|
||||
54
vendor/league/flysystem/readme.md
vendored
Normal file
54
vendor/league/flysystem/readme.md
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
# League\Flysystem
|
||||
|
||||
[](https://twitter.com/frankdejonge)
|
||||
[](https://github.com/thephpleague/flysystem)
|
||||
[](https://github.com/thephpleague/flysystem/releases)
|
||||
[](https://github.com/thephpleague/flysystem/blob/master/LICENSE)
|
||||
[](https://github.com/thephpleague/flysystem/actions?query=workflow%3A%22Quality+Assurance%22)
|
||||
[](https://packagist.org/packages/league/flysystem)
|
||||

|
||||
|
||||
## About Flysystem
|
||||
|
||||
Flysystem is a file storage library for PHP. It provides one interface to
|
||||
interact with many types of filesystems. When you use Flysystem, you're
|
||||
not only protected from vendor lock-in, you'll also have a consistent experience
|
||||
for which ever storage is right for you.
|
||||
|
||||
## Getting Started
|
||||
|
||||
* **[New in V3](https://flysystem.thephpleague.com/docs/what-is-new/)**: What is new in Flysystem V2/V3?
|
||||
* **[Architecture](https://flysystem.thephpleague.com/docs/architecture/)**: Flysystem's internal architecture
|
||||
* **[Flysystem API](https://flysystem.thephpleague.com/docs/usage/filesystem-api/)**: How to interact with your Flysystem instance
|
||||
* **[Upgrade from 1x](https://flysystem.thephpleague.com/docs/upgrade-from-1.x/)**: How to upgrade from 1.x/2.x
|
||||
|
||||
### Officially supported adapters
|
||||
|
||||
* **[Local](https://flysystem.thephpleague.com/docs/adapter/local/)**
|
||||
* **[FTP](https://flysystem.thephpleague.com/docs/adapter/ftp/)**
|
||||
* **[SFTP](https://flysystem.thephpleague.com/docs/adapter/sftp-v3/)**
|
||||
* **[Memory](https://flysystem.thephpleague.com/docs/adapter/in-memory/)**
|
||||
* **[AWS S3](https://flysystem.thephpleague.com/docs/adapter/aws-s3-v3/)**
|
||||
* **[AsyncAws S3](https://flysystem.thephpleague.com/docs/adapter/async-aws-s3/)**
|
||||
* **[Google Cloud Storage](https://flysystem.thephpleague.com/docs/adapter/google-cloud-storage/)**
|
||||
* **[Azure Blob Storage](https://flysystem.thephpleague.com/docs/adapter/azure-blob-storage/)**
|
||||
* **[WebDAV](https://flysystem.thephpleague.com/docs/adapter/webdav/)**
|
||||
|
||||
### Third party Adapters
|
||||
|
||||
* **[Gitlab](https://github.com/RoyVoetman/flysystem-gitlab-storage)**
|
||||
* **[Google Drive (using regular paths)](https://github.com/masbug/flysystem-google-drive-ext)**
|
||||
* **[bunny.net / BunnyCDN](https://github.com/PlatformCommunity/flysystem-bunnycdn/tree/v3)**
|
||||
* **[Sharepoint 365 / One Drive (Using MS Graph)](https://github.com/shitware-ltd/flysystem-msgraph)**
|
||||
* **[OneDrive](https://github.com/doerffler/flysystem-onedrive)**
|
||||
* **[Dropbox](https://github.com/spatie/flysystem-dropbox)**
|
||||
|
||||
You can always [create an adapter](https://flysystem.thephpleague.com/v2/docs/advanced/creating-an-adapter/) yourself.
|
||||
|
||||
## Security
|
||||
|
||||
If you discover any security related issues, please email info@frankdejonge.nl instead of using the issue tracker.
|
||||
|
||||
## Enjoy
|
||||
|
||||
Oh, and if you've come down this far, you might as well follow me on [twitter](https://twitter.com/frankdejonge).
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
use League\Flysystem\AdapterInterface;
|
||||
|
||||
abstract class AbstractAdapter implements AdapterInterface
|
||||
{
|
||||
/**
|
||||
* @var string|null path prefix
|
||||
*/
|
||||
protected $pathPrefix;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $pathSeparator = '/';
|
||||
|
||||
/**
|
||||
* Set the path prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPathPrefix($prefix)
|
||||
{
|
||||
$prefix = (string) $prefix;
|
||||
|
||||
if ($prefix === '') {
|
||||
$this->pathPrefix = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->pathPrefix = rtrim($prefix, '\\/') . $this->pathSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path prefix.
|
||||
*
|
||||
* @return string|null path prefix or null if pathPrefix is empty
|
||||
*/
|
||||
public function getPathPrefix()
|
||||
{
|
||||
return $this->pathPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix a path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string prefixed path
|
||||
*/
|
||||
public function applyPathPrefix($path)
|
||||
{
|
||||
return $this->getPathPrefix() . ltrim($path, '\\/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a path prefix.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string path without the prefix
|
||||
*/
|
||||
public function removePathPrefix($path)
|
||||
{
|
||||
return substr($path, strlen((string) $this->getPathPrefix()));
|
||||
}
|
||||
}
|
||||
@@ -1,705 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
use DateTime;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\NotSupportedException;
|
||||
use League\Flysystem\SafeStorage;
|
||||
use RuntimeException;
|
||||
|
||||
abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $host;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $port = 21;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $ssl = false;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $timeout = 90;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $passive = true;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $separator = '/';
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $root;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $permPublic = 0744;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $permPrivate = 0700;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $configurable = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $systemType;
|
||||
|
||||
/**
|
||||
* @var SafeStorage
|
||||
*/
|
||||
protected $safeStorage;
|
||||
|
||||
/**
|
||||
* True to enable timestamps for FTP servers that return unix-style listings.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $enableTimestampsOnUnixListings = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
{
|
||||
$this->safeStorage = new SafeStorage();
|
||||
$this->setConfig($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the config.
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConfig(array $config)
|
||||
{
|
||||
foreach ($this->configurable as $setting) {
|
||||
if ( ! isset($config[$setting])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = 'set' . ucfirst($setting);
|
||||
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($config[$setting]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the host.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the host.
|
||||
*
|
||||
* @param string $host
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHost($host)
|
||||
{
|
||||
$this->host = $host;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the public permission value.
|
||||
*
|
||||
* @param int $permPublic
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPermPublic($permPublic)
|
||||
{
|
||||
$this->permPublic = $permPublic;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the private permission value.
|
||||
*
|
||||
* @param int $permPrivate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPermPrivate($permPrivate)
|
||||
{
|
||||
$this->permPrivate = $permPrivate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ftp port.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPort()
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the root folder to work from.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRoot()
|
||||
{
|
||||
return $this->root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ftp port.
|
||||
*
|
||||
* @param int|string $port
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPort($port)
|
||||
{
|
||||
$this->port = (int) $port;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root folder to work from.
|
||||
*
|
||||
* @param string $root
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRoot($root)
|
||||
{
|
||||
$this->root = rtrim($root, '\\/') . $this->separator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ftp username.
|
||||
*
|
||||
* @return string username
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
$username = $this->safeStorage->retrieveSafely('username');
|
||||
|
||||
return $username !== null ? $username : 'anonymous';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ftp username.
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
$this->safeStorage->storeSafely('username', $username);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password.
|
||||
*
|
||||
* @return string password
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->safeStorage->retrieveSafely('password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ftp password.
|
||||
*
|
||||
* @param string $password
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->safeStorage->storeSafely('password', $password);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of seconds before the connection will timeout.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTimeout()
|
||||
{
|
||||
return $this->timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the amount of seconds before the connection should timeout.
|
||||
*
|
||||
* @param int $timeout
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimeout($timeout)
|
||||
{
|
||||
$this->timeout = (int) $timeout;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the FTP system type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSystemType()
|
||||
{
|
||||
return $this->systemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the FTP system type (windows or unix).
|
||||
*
|
||||
* @param string $systemType
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSystemType($systemType)
|
||||
{
|
||||
$this->systemType = strtolower($systemType);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* True to enable timestamps for FTP servers that return unix-style listings.
|
||||
*
|
||||
* @param bool $bool
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnableTimestampsOnUnixListings($bool = false)
|
||||
{
|
||||
$this->enableTimestampsOnUnixListings = $bool;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function listContents($directory = '', $recursive = false)
|
||||
{
|
||||
return $this->listDirectoryContents($directory, $recursive);
|
||||
}
|
||||
|
||||
abstract protected function listDirectoryContents($directory, $recursive = false);
|
||||
|
||||
/**
|
||||
* Normalize a directory listing.
|
||||
*
|
||||
* @param array $listing
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return array directory listing
|
||||
*/
|
||||
protected function normalizeListing(array $listing, $prefix = '')
|
||||
{
|
||||
$base = $prefix;
|
||||
$result = [];
|
||||
$listing = $this->removeDotDirectories($listing);
|
||||
|
||||
while ($item = array_shift($listing)) {
|
||||
if (preg_match('#^.*:$#', $item)) {
|
||||
$base = preg_replace('~^\./*|:$~', '', $item);
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = $this->normalizeObject($item, $base);
|
||||
}
|
||||
|
||||
return $this->sortListing($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort a directory listing.
|
||||
*
|
||||
* @param array $result
|
||||
*
|
||||
* @return array sorted listing
|
||||
*/
|
||||
protected function sortListing(array $result)
|
||||
{
|
||||
$compare = function ($one, $two) {
|
||||
return strnatcmp($one['path'], $two['path']);
|
||||
};
|
||||
|
||||
usort($result, $compare);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a file entry.
|
||||
*
|
||||
* @param string $item
|
||||
* @param string $base
|
||||
*
|
||||
* @return array normalized file array
|
||||
*
|
||||
* @throws NotSupportedException
|
||||
*/
|
||||
protected function normalizeObject($item, $base)
|
||||
{
|
||||
$systemType = $this->systemType ?: $this->detectSystemType($item);
|
||||
|
||||
if ($systemType === 'unix') {
|
||||
return $this->normalizeUnixObject($item, $base);
|
||||
} elseif ($systemType === 'windows') {
|
||||
return $this->normalizeWindowsObject($item, $base);
|
||||
}
|
||||
|
||||
throw NotSupportedException::forFtpSystemType($systemType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a Unix file entry.
|
||||
*
|
||||
* Given $item contains:
|
||||
* '-rw-r--r-- 1 ftp ftp 409 Aug 19 09:01 file1.txt'
|
||||
*
|
||||
* This function will return:
|
||||
* [
|
||||
* 'type' => 'file',
|
||||
* 'path' => 'file1.txt',
|
||||
* 'visibility' => 'public',
|
||||
* 'size' => 409,
|
||||
* 'timestamp' => 1566205260
|
||||
* ]
|
||||
*
|
||||
* @param string $item
|
||||
* @param string $base
|
||||
*
|
||||
* @return array normalized file array
|
||||
*/
|
||||
protected function normalizeUnixObject($item, $base)
|
||||
{
|
||||
$item = preg_replace('#\s+#', ' ', trim($item), 7);
|
||||
|
||||
if (count(explode(' ', $item, 9)) !== 9) {
|
||||
throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts.");
|
||||
}
|
||||
|
||||
list($permissions, /* $number */, /* $owner */, /* $group */, $size, $month, $day, $timeOrYear, $name) = explode(' ', $item, 9);
|
||||
$type = $this->detectType($permissions);
|
||||
$path = $base === '' ? $name : $base . $this->separator . $name;
|
||||
|
||||
if ($type === 'dir') {
|
||||
$result = compact('type', 'path');
|
||||
if ($this->enableTimestampsOnUnixListings) {
|
||||
$timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear);
|
||||
$result += compact('timestamp');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$permissions = $this->normalizePermissions($permissions);
|
||||
$visibility = $permissions & 0044 ? AdapterInterface::VISIBILITY_PUBLIC : AdapterInterface::VISIBILITY_PRIVATE;
|
||||
$size = (int) $size;
|
||||
|
||||
$result = compact('type', 'path', 'visibility', 'size');
|
||||
if ($this->enableTimestampsOnUnixListings) {
|
||||
$timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear);
|
||||
$result += compact('timestamp');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only accurate to the minute (current year), or to the day.
|
||||
*
|
||||
* Inadequacies in timestamp accuracy are due to limitations of the FTP 'LIST' command
|
||||
*
|
||||
* Note: The 'MLSD' command is a machine-readable replacement for 'LIST'
|
||||
* but many FTP servers do not support it :(
|
||||
*
|
||||
* @param string $month e.g. 'Aug'
|
||||
* @param string $day e.g. '19'
|
||||
* @param string $timeOrYear e.g. '09:01' OR '2015'
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function normalizeUnixTimestamp($month, $day, $timeOrYear)
|
||||
{
|
||||
if (is_numeric($timeOrYear)) {
|
||||
$year = $timeOrYear;
|
||||
$hour = '00';
|
||||
$minute = '00';
|
||||
$seconds = '00';
|
||||
} else {
|
||||
$year = date('Y');
|
||||
list($hour, $minute) = explode(':', $timeOrYear);
|
||||
$seconds = '00';
|
||||
}
|
||||
$dateTime = DateTime::createFromFormat('Y-M-j-G:i:s', "{$year}-{$month}-{$day}-{$hour}:{$minute}:{$seconds}");
|
||||
|
||||
return $dateTime->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a Windows/DOS file entry.
|
||||
*
|
||||
* @param string $item
|
||||
* @param string $base
|
||||
*
|
||||
* @return array normalized file array
|
||||
*/
|
||||
protected function normalizeWindowsObject($item, $base)
|
||||
{
|
||||
$item = preg_replace('#\s+#', ' ', trim($item), 3);
|
||||
|
||||
if (count(explode(' ', $item, 4)) !== 4) {
|
||||
throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts.");
|
||||
}
|
||||
|
||||
list($date, $time, $size, $name) = explode(' ', $item, 4);
|
||||
$path = $base === '' ? $name : $base . $this->separator . $name;
|
||||
|
||||
// Check for the correct date/time format
|
||||
$format = strlen($date) === 8 ? 'm-d-yH:iA' : 'Y-m-dH:i';
|
||||
$dt = DateTime::createFromFormat($format, $date . $time);
|
||||
$timestamp = $dt ? $dt->getTimestamp() : (int) strtotime("$date $time");
|
||||
|
||||
if ($size === '<DIR>') {
|
||||
$type = 'dir';
|
||||
|
||||
return compact('type', 'path', 'timestamp');
|
||||
}
|
||||
|
||||
$type = 'file';
|
||||
$visibility = AdapterInterface::VISIBILITY_PUBLIC;
|
||||
$size = (int) $size;
|
||||
|
||||
return compact('type', 'path', 'visibility', 'size', 'timestamp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system type from a listing item.
|
||||
*
|
||||
* @param string $item
|
||||
*
|
||||
* @return string the system type
|
||||
*/
|
||||
protected function detectSystemType($item)
|
||||
{
|
||||
return preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', trim($item)) ? 'windows' : 'unix';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file type from the permissions.
|
||||
*
|
||||
* @param string $permissions
|
||||
*
|
||||
* @return string file type
|
||||
*/
|
||||
protected function detectType($permissions)
|
||||
{
|
||||
return substr($permissions, 0, 1) === 'd' ? 'dir' : 'file';
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a permissions string.
|
||||
*
|
||||
* @param string $permissions
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function normalizePermissions($permissions)
|
||||
{
|
||||
if (is_numeric($permissions)) {
|
||||
return ((int) $permissions) & 0777;
|
||||
}
|
||||
|
||||
// remove the type identifier
|
||||
$permissions = substr($permissions, 1);
|
||||
|
||||
// map the string rights to the numeric counterparts
|
||||
$map = ['-' => '0', 'r' => '4', 'w' => '2', 'x' => '1'];
|
||||
$permissions = strtr($permissions, $map);
|
||||
|
||||
// split up the permission groups
|
||||
$parts = str_split($permissions, 3);
|
||||
|
||||
// convert the groups
|
||||
$mapper = function ($part) {
|
||||
return array_sum(str_split($part));
|
||||
};
|
||||
|
||||
// converts to decimal number
|
||||
return octdec(implode('', array_map($mapper, $parts)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out dot-directories.
|
||||
*
|
||||
* @param array $list
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function removeDotDirectories(array $list)
|
||||
{
|
||||
$filter = function ($line) {
|
||||
return $line !== '' && ! preg_match('#.* \.(\.)?$|^total#', $line);
|
||||
};
|
||||
|
||||
return array_filter($list, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function has($path)
|
||||
{
|
||||
return $this->getMetadata($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getSize($path)
|
||||
{
|
||||
return $this->getMetadata($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getVisibility($path)
|
||||
{
|
||||
return $this->getMetadata($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure a directory exists.
|
||||
*
|
||||
* @param string $dirname
|
||||
*/
|
||||
public function ensureDirectory($dirname)
|
||||
{
|
||||
$dirname = (string) $dirname;
|
||||
|
||||
if ($dirname !== '' && ! $this->has($dirname)) {
|
||||
$this->createDir($dirname, new Config());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
if ( ! $this->isConnected()) {
|
||||
$this->disconnect();
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the public permission value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPermPublic()
|
||||
{
|
||||
return $this->permPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the private permission value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPermPrivate()
|
||||
{
|
||||
return $this->permPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect on destruction.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish a connection.
|
||||
*/
|
||||
abstract public function connect();
|
||||
|
||||
/**
|
||||
* Close the connection.
|
||||
*/
|
||||
abstract public function disconnect();
|
||||
|
||||
/**
|
||||
* Check if a connection is active.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isConnected();
|
||||
|
||||
protected function escapePath($path)
|
||||
{
|
||||
return str_replace(['*', '[', ']'], ['\\*', '\\[', '\\]'], $path);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
/**
|
||||
* Adapters that implement this interface let the Filesystem know that files can be overwritten using the write
|
||||
* functions and don't need the update function to be called. This can help improve performance when asserts are disabled.
|
||||
*/
|
||||
interface CanOverwriteFiles
|
||||
{
|
||||
}
|
||||
584
vendor/league/flysystem/src/Adapter/Ftp.php
vendored
584
vendor/league/flysystem/src/Adapter/Ftp.php
vendored
@@ -1,584 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\ConnectionErrorException;
|
||||
use League\Flysystem\ConnectionRuntimeException;
|
||||
use League\Flysystem\InvalidRootException;
|
||||
use League\Flysystem\Util;
|
||||
use League\Flysystem\Util\MimeType;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class Ftp extends AbstractFtpAdapter
|
||||
{
|
||||
use StreamedCopyTrait;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $transferMode = FTP_BINARY;
|
||||
|
||||
/**
|
||||
* @var null|bool
|
||||
*/
|
||||
protected $ignorePassiveAddress = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $recurseManually = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $utf8 = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $configurable = [
|
||||
'host',
|
||||
'port',
|
||||
'username',
|
||||
'password',
|
||||
'ssl',
|
||||
'timeout',
|
||||
'root',
|
||||
'permPrivate',
|
||||
'permPublic',
|
||||
'passive',
|
||||
'transferMode',
|
||||
'systemType',
|
||||
'ignorePassiveAddress',
|
||||
'recurseManually',
|
||||
'utf8',
|
||||
'enableTimestampsOnUnixListings',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isPureFtpd;
|
||||
|
||||
/**
|
||||
* Set the transfer mode.
|
||||
*
|
||||
* @param int $mode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTransferMode($mode)
|
||||
{
|
||||
$this->transferMode = $mode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if Ssl is enabled.
|
||||
*
|
||||
* @param bool $ssl
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSsl($ssl)
|
||||
{
|
||||
$this->ssl = (bool) $ssl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if passive mode should be used.
|
||||
*
|
||||
* @param bool $passive
|
||||
*/
|
||||
public function setPassive($passive = true)
|
||||
{
|
||||
$this->passive = $passive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $ignorePassiveAddress
|
||||
*/
|
||||
public function setIgnorePassiveAddress($ignorePassiveAddress)
|
||||
{
|
||||
$this->ignorePassiveAddress = $ignorePassiveAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $recurseManually
|
||||
*/
|
||||
public function setRecurseManually($recurseManually)
|
||||
{
|
||||
$this->recurseManually = $recurseManually;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $utf8
|
||||
*/
|
||||
public function setUtf8($utf8)
|
||||
{
|
||||
$this->utf8 = (bool) $utf8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the FTP server.
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
$tries = 3;
|
||||
start_connecting:
|
||||
|
||||
if ($this->ssl) {
|
||||
$this->connection = @ftp_ssl_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
} else {
|
||||
$this->connection = @ftp_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
}
|
||||
|
||||
if ( ! $this->connection) {
|
||||
$tries--;
|
||||
|
||||
if ($tries > 0) goto start_connecting;
|
||||
|
||||
throw new ConnectionRuntimeException('Could not connect to host: ' . $this->getHost() . ', port:' . $this->getPort());
|
||||
}
|
||||
|
||||
$this->login();
|
||||
$this->setUtf8Mode();
|
||||
$this->setConnectionPassiveMode();
|
||||
$this->setConnectionRoot();
|
||||
$this->isPureFtpd = $this->isPureFtpdServer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the connection to UTF-8 mode.
|
||||
*/
|
||||
protected function setUtf8Mode()
|
||||
{
|
||||
if ($this->utf8) {
|
||||
$response = ftp_raw($this->connection, "OPTS UTF8 ON");
|
||||
if (!in_array(substr($response[0], 0, 3), ['200', '202'])) {
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not set UTF-8 mode for connection: ' . $this->getHost() . '::' . $this->getPort()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the connections to passive mode.
|
||||
*
|
||||
* @throws ConnectionRuntimeException
|
||||
*/
|
||||
protected function setConnectionPassiveMode()
|
||||
{
|
||||
if (is_bool($this->ignorePassiveAddress) && defined('FTP_USEPASVADDRESS')) {
|
||||
ftp_set_option($this->connection, FTP_USEPASVADDRESS, ! $this->ignorePassiveAddress);
|
||||
}
|
||||
|
||||
if ( ! ftp_pasv($this->connection, $this->passive)) {
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not set passive mode for connection: ' . $this->getHost() . '::' . $this->getPort()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the connection root.
|
||||
*/
|
||||
protected function setConnectionRoot()
|
||||
{
|
||||
$root = $this->getRoot();
|
||||
$connection = $this->connection;
|
||||
|
||||
if ($root && ! ftp_chdir($connection, $root)) {
|
||||
throw new InvalidRootException('Root is invalid or does not exist: ' . $this->getRoot());
|
||||
}
|
||||
|
||||
// Store absolute path for further reference.
|
||||
// This is needed when creating directories and
|
||||
// initial root was a relative path, else the root
|
||||
// would be relative to the chdir'd path.
|
||||
$this->root = ftp_pwd($connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Login.
|
||||
*
|
||||
* @throws ConnectionRuntimeException
|
||||
*/
|
||||
protected function login()
|
||||
{
|
||||
set_error_handler(function () {
|
||||
});
|
||||
$isLoggedIn = ftp_login(
|
||||
$this->connection,
|
||||
$this->getUsername(),
|
||||
$this->getPassword()
|
||||
);
|
||||
restore_error_handler();
|
||||
|
||||
if ( ! $isLoggedIn) {
|
||||
$this->disconnect();
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not login with connection: ' . $this->getHost() . '::' . $this->getPort(
|
||||
) . ', username: ' . $this->getUsername()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from the FTP server.
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
if ($this->hasFtpConnection()) {
|
||||
@ftp_close($this->connection);
|
||||
}
|
||||
|
||||
$this->connection = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function write($path, $contents, Config $config)
|
||||
{
|
||||
$stream = fopen('php://temp', 'w+b');
|
||||
fwrite($stream, $contents);
|
||||
rewind($stream);
|
||||
$result = $this->writeStream($path, $stream, $config);
|
||||
fclose($stream);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result['contents'] = $contents;
|
||||
$result['mimetype'] = $config->get('mimetype') ?: Util::guessMimeType($path, $contents);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function writeStream($path, $resource, Config $config)
|
||||
{
|
||||
$this->ensureDirectory(Util::dirname($path));
|
||||
|
||||
if ( ! ftp_fput($this->getConnection(), $path, $resource, $this->transferMode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($visibility = $config->get('visibility')) {
|
||||
$this->setVisibility($path, $visibility);
|
||||
}
|
||||
|
||||
$type = 'file';
|
||||
|
||||
return compact('type', 'path', 'visibility');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function update($path, $contents, Config $config)
|
||||
{
|
||||
return $this->write($path, $contents, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function updateStream($path, $resource, Config $config)
|
||||
{
|
||||
return $this->writeStream($path, $resource, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rename($path, $newpath)
|
||||
{
|
||||
return ftp_rename($this->getConnection(), $path, $newpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function delete($path)
|
||||
{
|
||||
return ftp_delete($this->getConnection(), $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function deleteDir($dirname)
|
||||
{
|
||||
$connection = $this->getConnection();
|
||||
$contents = array_reverse($this->listDirectoryContents($dirname, false));
|
||||
|
||||
foreach ($contents as $object) {
|
||||
if ($object['type'] === 'file') {
|
||||
if ( ! ftp_delete($connection, $object['path'])) {
|
||||
return false;
|
||||
}
|
||||
} elseif ( ! $this->deleteDir($object['path'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ftp_rmdir($connection, $dirname);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function createDir($dirname, Config $config)
|
||||
{
|
||||
$connection = $this->getConnection();
|
||||
$directories = explode('/', $dirname);
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
if (false === $this->createActualDirectory($directory, $connection)) {
|
||||
$this->setConnectionRoot();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ftp_chdir($connection, $directory);
|
||||
}
|
||||
|
||||
$this->setConnectionRoot();
|
||||
|
||||
return ['type' => 'dir', 'path' => $dirname];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @param resource $connection
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function createActualDirectory($directory, $connection)
|
||||
{
|
||||
// List the current directory
|
||||
$listing = ftp_nlist($connection, '.') ?: [];
|
||||
|
||||
foreach ($listing as $key => $item) {
|
||||
if (preg_match('~^\./.*~', $item)) {
|
||||
$listing[$key] = substr($item, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($directory, $listing, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (boolean) ftp_mkdir($connection, $directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMetadata($path)
|
||||
{
|
||||
if ($path === '') {
|
||||
return ['type' => 'dir', 'path' => ''];
|
||||
}
|
||||
|
||||
if (@ftp_chdir($this->getConnection(), $path) === true) {
|
||||
$this->setConnectionRoot();
|
||||
|
||||
return ['type' => 'dir', 'path' => $path];
|
||||
}
|
||||
|
||||
$listing = $this->ftpRawlist('-A', $path);
|
||||
|
||||
if (empty($listing) || in_array('total 0', $listing, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (preg_match('/.* not found/', $listing[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (preg_match('/^total [0-9]*$/', $listing[0])) {
|
||||
array_shift($listing);
|
||||
}
|
||||
|
||||
return $this->normalizeObject($listing[0], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMimetype($path)
|
||||
{
|
||||
if ( ! $metadata = $this->getMetadata($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$metadata['mimetype'] = MimeType::detectByFilename($path);
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getTimestamp($path)
|
||||
{
|
||||
$timestamp = ftp_mdtm($this->getConnection(), $path);
|
||||
|
||||
return ($timestamp !== -1) ? ['path' => $path, 'timestamp' => $timestamp] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function read($path)
|
||||
{
|
||||
if ( ! $object = $this->readStream($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$object['contents'] = stream_get_contents($object['stream']);
|
||||
fclose($object['stream']);
|
||||
unset($object['stream']);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function readStream($path)
|
||||
{
|
||||
$stream = fopen('php://temp', 'w+b');
|
||||
$result = ftp_fget($this->getConnection(), $stream, $path, $this->transferMode);
|
||||
rewind($stream);
|
||||
|
||||
if ( ! $result) {
|
||||
fclose($stream);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return ['type' => 'file', 'path' => $path, 'stream' => $stream];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setVisibility($path, $visibility)
|
||||
{
|
||||
$mode = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? $this->getPermPublic() : $this->getPermPrivate();
|
||||
|
||||
if ( ! ftp_chmod($this->getConnection(), $mode, $path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return compact('path', 'visibility');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
protected function listDirectoryContents($directory, $recursive = true)
|
||||
{
|
||||
if ($recursive && $this->recurseManually) {
|
||||
return $this->listDirectoryContentsRecursive($directory);
|
||||
}
|
||||
|
||||
$options = $recursive ? '-alnR' : '-aln';
|
||||
$listing = $this->ftpRawlist($options, $directory);
|
||||
|
||||
return $listing ? $this->normalizeListing($listing, $directory) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
protected function listDirectoryContentsRecursive($directory)
|
||||
{
|
||||
$listing = $this->normalizeListing($this->ftpRawlist('-aln', $directory) ?: [], $directory);
|
||||
$output = [];
|
||||
|
||||
foreach ($listing as $item) {
|
||||
$output[] = $item;
|
||||
if ($item['type'] !== 'dir') {
|
||||
continue;
|
||||
}
|
||||
$output = array_merge($output, $this->listDirectoryContentsRecursive($item['path']));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the connection is open.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws ConnectionErrorException
|
||||
*/
|
||||
public function isConnected()
|
||||
{
|
||||
return $this->hasFtpConnection() && $this->getRawExecResponseCode('NOOP') === 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isPureFtpdServer()
|
||||
{
|
||||
$response = ftp_raw($this->connection, 'HELP');
|
||||
|
||||
return stripos(implode(' ', $response), 'Pure-FTPd') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ftp_rawlist function with optional escaping.
|
||||
*
|
||||
* @param string $options
|
||||
* @param string $path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function ftpRawlist($options, $path)
|
||||
{
|
||||
$connection = $this->getConnection();
|
||||
|
||||
if ($this->isPureFtpd) {
|
||||
$path = str_replace([' ', '[', ']'], ['\ ', '\\[', '\\]'], $path);
|
||||
}
|
||||
|
||||
return ftp_rawlist($connection, $options . ' ' . $this->escapePath($path));
|
||||
}
|
||||
|
||||
private function getRawExecResponseCode($command)
|
||||
{
|
||||
$response = @ftp_raw($this->connection, trim($command)) ?: [];
|
||||
|
||||
return (int) preg_replace('/\D/', '', implode(' ', (array) $response));
|
||||
}
|
||||
|
||||
private function hasFtpConnection(): bool
|
||||
{
|
||||
return is_resource($this->connection) || $this->connection instanceof \FTP\Connection;
|
||||
}
|
||||
}
|
||||
48
vendor/league/flysystem/src/Adapter/Ftpd.php
vendored
48
vendor/league/flysystem/src/Adapter/Ftpd.php
vendored
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
class Ftpd extends Ftp
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMetadata($path)
|
||||
{
|
||||
if ($path === '') {
|
||||
return ['type' => 'dir', 'path' => ''];
|
||||
}
|
||||
|
||||
if (@ftp_chdir($this->getConnection(), $path) === true) {
|
||||
$this->setConnectionRoot();
|
||||
|
||||
return ['type' => 'dir', 'path' => $path];
|
||||
}
|
||||
|
||||
$object = ftp_raw($this->getConnection(), 'STAT ' . $this->escapePath($path));
|
||||
|
||||
if ( ! $object || count($object) < 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (substr($object[1], 0, 5) === "ftpd:") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->normalizeObject($object[1], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function listDirectoryContents($directory, $recursive = true)
|
||||
{
|
||||
$listing = ftp_rawlist($this->getConnection(), $this->escapePath($directory), $recursive);
|
||||
|
||||
if ($listing === false || ( ! empty($listing) && substr($listing[0], 0, 5) === "ftpd:")) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->normalizeListing($listing, $directory);
|
||||
}
|
||||
}
|
||||
533
vendor/league/flysystem/src/Adapter/Local.php
vendored
533
vendor/league/flysystem/src/Adapter/Local.php
vendored
@@ -1,533 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
use DirectoryIterator;
|
||||
use FilesystemIterator;
|
||||
use finfo as Finfo;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\Exception;
|
||||
use League\Flysystem\NotSupportedException;
|
||||
use League\Flysystem\UnreadableFileException;
|
||||
use League\Flysystem\Util;
|
||||
use LogicException;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use SplFileInfo;
|
||||
|
||||
class Local extends AbstractAdapter
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const SKIP_LINKS = 0001;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
const DISALLOW_LINKS = 0002;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $permissions = [
|
||||
'file' => [
|
||||
'public' => 0644,
|
||||
'private' => 0600,
|
||||
],
|
||||
'dir' => [
|
||||
'public' => 0755,
|
||||
'private' => 0700,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $pathSeparator = DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $permissionMap;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $writeFlags;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $linkHandling;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $root
|
||||
* @param int $writeFlags
|
||||
* @param int $linkHandling
|
||||
* @param array $permissions
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function __construct($root, $writeFlags = LOCK_EX, $linkHandling = self::DISALLOW_LINKS, array $permissions = [])
|
||||
{
|
||||
$root = is_link($root) ? realpath($root) : $root;
|
||||
$this->permissionMap = array_replace_recursive(static::$permissions, $permissions);
|
||||
$this->ensureDirectory($root);
|
||||
|
||||
if ( ! is_dir($root) || ! is_readable($root)) {
|
||||
throw new LogicException('The root path ' . $root . ' is not readable.');
|
||||
}
|
||||
|
||||
$this->setPathPrefix($root);
|
||||
$this->writeFlags = $writeFlags;
|
||||
$this->linkHandling = $linkHandling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the root directory exists.
|
||||
*
|
||||
* @param string $root root directory path
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception in case the root directory can not be created
|
||||
*/
|
||||
protected function ensureDirectory($root)
|
||||
{
|
||||
if ( ! is_dir($root)) {
|
||||
$umask = umask(0);
|
||||
|
||||
if ( ! @mkdir($root, $this->permissionMap['dir']['public'], true)) {
|
||||
$mkdirError = error_get_last();
|
||||
}
|
||||
|
||||
umask($umask);
|
||||
clearstatcache(false, $root);
|
||||
|
||||
if ( ! is_dir($root)) {
|
||||
$errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : '';
|
||||
throw new Exception(sprintf('Impossible to create the root directory "%s". %s', $root, $errorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function has($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
|
||||
return file_exists($location);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function write($path, $contents, Config $config)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$this->ensureDirectory(dirname($location));
|
||||
|
||||
if (($size = file_put_contents($location, $contents, $this->writeFlags)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = 'file';
|
||||
$result = compact('contents', 'type', 'size', 'path');
|
||||
|
||||
if ($visibility = $config->get('visibility')) {
|
||||
$result['visibility'] = $visibility;
|
||||
$this->setVisibility($path, $visibility);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function writeStream($path, $resource, Config $config)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$this->ensureDirectory(dirname($location));
|
||||
$stream = fopen($location, 'w+b');
|
||||
|
||||
if ( ! $stream || stream_copy_to_stream($resource, $stream) === false || ! fclose($stream)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = 'file';
|
||||
$result = compact('type', 'path');
|
||||
|
||||
if ($visibility = $config->get('visibility')) {
|
||||
$this->setVisibility($path, $visibility);
|
||||
$result['visibility'] = $visibility;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function readStream($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$stream = fopen($location, 'rb');
|
||||
|
||||
return ['type' => 'file', 'path' => $path, 'stream' => $stream];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function updateStream($path, $resource, Config $config)
|
||||
{
|
||||
return $this->writeStream($path, $resource, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function update($path, $contents, Config $config)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$size = file_put_contents($location, $contents, $this->writeFlags);
|
||||
|
||||
if ($size === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = 'file';
|
||||
|
||||
$result = compact('type', 'path', 'size', 'contents');
|
||||
|
||||
if ($visibility = $config->get('visibility')) {
|
||||
$this->setVisibility($path, $visibility);
|
||||
$result['visibility'] = $visibility;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function read($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$contents = @file_get_contents($location);
|
||||
|
||||
if ($contents === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ['type' => 'file', 'path' => $path, 'contents' => $contents];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rename($path, $newpath)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$destination = $this->applyPathPrefix($newpath);
|
||||
$parentDirectory = $this->applyPathPrefix(Util::dirname($newpath));
|
||||
$this->ensureDirectory($parentDirectory);
|
||||
|
||||
return rename($location, $destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function copy($path, $newpath)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$destination = $this->applyPathPrefix($newpath);
|
||||
$this->ensureDirectory(dirname($destination));
|
||||
|
||||
return copy($location, $destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function delete($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
|
||||
return @unlink($location);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function listContents($directory = '', $recursive = false)
|
||||
{
|
||||
$result = [];
|
||||
$location = $this->applyPathPrefix($directory);
|
||||
|
||||
if ( ! is_dir($location)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$iterator = $recursive ? $this->getRecursiveDirectoryIterator($location) : $this->getDirectoryIterator($location);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$path = $this->getFilePath($file);
|
||||
|
||||
if (preg_match('#(^|/|\\\\)\.{1,2}$#', $path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = $this->normalizeFileInfo($file);
|
||||
}
|
||||
|
||||
unset($iterator);
|
||||
|
||||
return array_filter($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMetadata($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
clearstatcache(false, $location);
|
||||
$info = new SplFileInfo($location);
|
||||
|
||||
return $this->normalizeFileInfo($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getSize($path)
|
||||
{
|
||||
return $this->getMetadata($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMimetype($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$finfo = new Finfo(FILEINFO_MIME_TYPE);
|
||||
$mimetype = $finfo->file($location);
|
||||
|
||||
if (in_array($mimetype, ['application/octet-stream', 'inode/x-empty', 'application/x-empty'])) {
|
||||
$mimetype = Util\MimeType::detectByFilename($location);
|
||||
}
|
||||
|
||||
return ['path' => $path, 'type' => 'file', 'mimetype' => $mimetype];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getTimestamp($path)
|
||||
{
|
||||
return $this->getMetadata($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getVisibility($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
clearstatcache(false, $location);
|
||||
$permissions = octdec(substr(sprintf('%o', fileperms($location)), -4));
|
||||
$type = is_dir($location) ? 'dir' : 'file';
|
||||
|
||||
foreach ($this->permissionMap[$type] as $visibility => $visibilityPermissions) {
|
||||
if ($visibilityPermissions == $permissions) {
|
||||
return compact('path', 'visibility');
|
||||
}
|
||||
}
|
||||
|
||||
$visibility = substr(sprintf('%o', fileperms($location)), -4);
|
||||
|
||||
return compact('path', 'visibility');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setVisibility($path, $visibility)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$type = is_dir($location) ? 'dir' : 'file';
|
||||
$success = chmod($location, $this->permissionMap[$type][$visibility]);
|
||||
|
||||
if ($success === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return compact('path', 'visibility');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function createDir($dirname, Config $config)
|
||||
{
|
||||
$location = $this->applyPathPrefix($dirname);
|
||||
$umask = umask(0);
|
||||
$visibility = $config->get('visibility', 'public');
|
||||
$return = ['path' => $dirname, 'type' => 'dir'];
|
||||
|
||||
if ( ! is_dir($location)) {
|
||||
if (false === @mkdir($location, $this->permissionMap['dir'][$visibility], true)
|
||||
|| false === is_dir($location)) {
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
|
||||
umask($umask);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function deleteDir($dirname)
|
||||
{
|
||||
$location = $this->applyPathPrefix($dirname);
|
||||
|
||||
if ( ! is_dir($location)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contents = $this->getRecursiveDirectoryIterator($location, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
/** @var SplFileInfo $file */
|
||||
foreach ($contents as $file) {
|
||||
$this->guardAgainstUnreadableFileInfo($file);
|
||||
$this->deleteFileInfoObject($file);
|
||||
}
|
||||
|
||||
unset($contents);
|
||||
|
||||
return rmdir($location);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SplFileInfo $file
|
||||
*/
|
||||
protected function deleteFileInfoObject(SplFileInfo $file)
|
||||
{
|
||||
switch ($file->getType()) {
|
||||
case 'dir':
|
||||
rmdir($file->getRealPath());
|
||||
break;
|
||||
case 'link':
|
||||
unlink($file->getPathname());
|
||||
break;
|
||||
default:
|
||||
unlink($file->getRealPath());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the file info.
|
||||
*
|
||||
* @param SplFileInfo $file
|
||||
*
|
||||
* @return array|void
|
||||
*
|
||||
* @throws NotSupportedException
|
||||
*/
|
||||
protected function normalizeFileInfo(SplFileInfo $file)
|
||||
{
|
||||
if ( ! $file->isLink()) {
|
||||
return $this->mapFileInfo($file);
|
||||
}
|
||||
|
||||
if ($this->linkHandling & self::DISALLOW_LINKS) {
|
||||
throw NotSupportedException::forLink($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the normalized path from a SplFileInfo object.
|
||||
*
|
||||
* @param SplFileInfo $file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFilePath(SplFileInfo $file)
|
||||
{
|
||||
$location = $file->getPathname();
|
||||
$path = $this->removePathPrefix($location);
|
||||
|
||||
return trim(str_replace('\\', '/', $path), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param int $mode
|
||||
*
|
||||
* @return RecursiveIteratorIterator
|
||||
*/
|
||||
protected function getRecursiveDirectoryIterator($path, $mode = RecursiveIteratorIterator::SELF_FIRST)
|
||||
{
|
||||
return new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
|
||||
$mode
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return DirectoryIterator
|
||||
*/
|
||||
protected function getDirectoryIterator($path)
|
||||
{
|
||||
$iterator = new DirectoryIterator($path);
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SplFileInfo $file
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function mapFileInfo(SplFileInfo $file)
|
||||
{
|
||||
$normalized = [
|
||||
'type' => $file->getType(),
|
||||
'path' => $this->getFilePath($file),
|
||||
];
|
||||
|
||||
$normalized['timestamp'] = $file->getMTime();
|
||||
|
||||
if ($normalized['type'] === 'file') {
|
||||
$normalized['size'] = $file->getSize();
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SplFileInfo $file
|
||||
*
|
||||
* @throws UnreadableFileException
|
||||
*/
|
||||
protected function guardAgainstUnreadableFileInfo(SplFileInfo $file)
|
||||
{
|
||||
if ( ! $file->isReadable()) {
|
||||
throw UnreadableFileException::forFileInfo($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
144
vendor/league/flysystem/src/Adapter/NullAdapter.php
vendored
144
vendor/league/flysystem/src/Adapter/NullAdapter.php
vendored
@@ -1,144 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
|
||||
use League\Flysystem\Adapter\Polyfill\StreamedTrait;
|
||||
use League\Flysystem\Config;
|
||||
|
||||
class NullAdapter extends AbstractAdapter
|
||||
{
|
||||
use StreamedTrait;
|
||||
use StreamedCopyTrait;
|
||||
|
||||
/**
|
||||
* Check whether a file is present.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function write($path, $contents, Config $config)
|
||||
{
|
||||
$type = 'file';
|
||||
$result = compact('contents', 'type', 'path');
|
||||
|
||||
if ($visibility = $config->get('visibility')) {
|
||||
$result['visibility'] = $visibility;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function update($path, $contents, Config $config)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function read($path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rename($path, $newpath)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function delete($path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function listContents($directory = '', $recursive = false)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMetadata($path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getSize($path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMimetype($path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getTimestamp($path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getVisibility($path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setVisibility($path, $visibility)
|
||||
{
|
||||
return compact('visibility');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function createDir($dirname, Config $config)
|
||||
{
|
||||
return ['path' => $dirname, 'type' => 'dir'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function deleteDir($dirname)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
use LogicException;
|
||||
|
||||
trait NotSupportingVisibilityTrait
|
||||
{
|
||||
/**
|
||||
* Get the visibility of a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function getVisibility($path)
|
||||
{
|
||||
throw new LogicException(get_class($this) . ' does not support visibility. Path: ' . $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visibility for a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $visibility
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function setVisibility($path, $visibility)
|
||||
{
|
||||
throw new LogicException(get_class($this) . ' does not support visibility. Path: ' . $path . ', visibility: ' . $visibility);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
use League\Flysystem\Config;
|
||||
|
||||
trait StreamedCopyTrait
|
||||
{
|
||||
/**
|
||||
* Copy a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $newpath
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($path, $newpath)
|
||||
{
|
||||
$response = $this->readStream($path);
|
||||
|
||||
if ($response === false || ! is_resource($response['stream'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->writeStream($newpath, $response['stream'], new Config());
|
||||
|
||||
if ($result !== false && is_resource($response['stream'])) {
|
||||
fclose($response['stream']);
|
||||
}
|
||||
|
||||
return $result !== false;
|
||||
}
|
||||
|
||||
// Required abstract method
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
abstract public function readStream($path);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
abstract public function writeStream($path, $resource, Config $config);
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
/**
|
||||
* A helper for adapters that only handle strings to provide read streams.
|
||||
*/
|
||||
trait StreamedReadingTrait
|
||||
{
|
||||
/**
|
||||
* Reads a file as a stream.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*
|
||||
* @see League\Flysystem\ReadInterface::readStream()
|
||||
*/
|
||||
public function readStream($path)
|
||||
{
|
||||
if ( ! $data = $this->read($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$stream = fopen('php://temp', 'w+b');
|
||||
fwrite($stream, $data['contents']);
|
||||
rewind($stream);
|
||||
$data['stream'] = $stream;
|
||||
unset($data['contents']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*
|
||||
* @see League\Flysystem\ReadInterface::read()
|
||||
*/
|
||||
abstract public function read($path);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
trait StreamedTrait
|
||||
{
|
||||
use StreamedReadingTrait;
|
||||
use StreamedWritingTrait;
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\Util;
|
||||
|
||||
trait StreamedWritingTrait
|
||||
{
|
||||
/**
|
||||
* Stream fallback delegator.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config
|
||||
* @param string $fallback
|
||||
*
|
||||
* @return mixed fallback result
|
||||
*/
|
||||
protected function stream($path, $resource, Config $config, $fallback)
|
||||
{
|
||||
Util::rewindStream($resource);
|
||||
$contents = stream_get_contents($resource);
|
||||
$fallbackCall = [$this, $fallback];
|
||||
|
||||
return call_user_func($fallbackCall, $path, $contents, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write using a stream.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config
|
||||
*
|
||||
* @return mixed false or file metadata
|
||||
*/
|
||||
public function writeStream($path, $resource, Config $config)
|
||||
{
|
||||
return $this->stream($path, $resource, $config, 'write');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a file using a stream.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config Config object or visibility setting
|
||||
*
|
||||
* @return mixed false of file metadata
|
||||
*/
|
||||
public function updateStream($path, $resource, Config $config)
|
||||
{
|
||||
return $this->stream($path, $resource, $config, 'update');
|
||||
}
|
||||
|
||||
// Required abstract methods
|
||||
abstract public function write($pash, $contents, Config $config);
|
||||
abstract public function update($pash, $contents, Config $config);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
class SynologyFtp extends Ftpd
|
||||
{
|
||||
// This class merely exists because of BC.
|
||||
}
|
||||
118
vendor/league/flysystem/src/AdapterInterface.php
vendored
118
vendor/league/flysystem/src/AdapterInterface.php
vendored
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface AdapterInterface extends ReadInterface
|
||||
{
|
||||
/**
|
||||
* @const VISIBILITY_PUBLIC public visibility
|
||||
*/
|
||||
const VISIBILITY_PUBLIC = 'public';
|
||||
|
||||
/**
|
||||
* @const VISIBILITY_PRIVATE private visibility
|
||||
*/
|
||||
const VISIBILITY_PRIVATE = 'private';
|
||||
|
||||
/**
|
||||
* Write a new file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $contents
|
||||
* @param Config $config Config object
|
||||
*
|
||||
* @return array|false false on failure file meta data on success
|
||||
*/
|
||||
public function write($path, $contents, Config $config);
|
||||
|
||||
/**
|
||||
* Write a new file using a stream.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config Config object
|
||||
*
|
||||
* @return array|false false on failure file meta data on success
|
||||
*/
|
||||
public function writeStream($path, $resource, Config $config);
|
||||
|
||||
/**
|
||||
* Update a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $contents
|
||||
* @param Config $config Config object
|
||||
*
|
||||
* @return array|false false on failure file meta data on success
|
||||
*/
|
||||
public function update($path, $contents, Config $config);
|
||||
|
||||
/**
|
||||
* Update a file using a stream.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config Config object
|
||||
*
|
||||
* @return array|false false on failure file meta data on success
|
||||
*/
|
||||
public function updateStream($path, $resource, Config $config);
|
||||
|
||||
/**
|
||||
* Rename a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $newpath
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rename($path, $newpath);
|
||||
|
||||
/**
|
||||
* Copy a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $newpath
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($path, $newpath);
|
||||
|
||||
/**
|
||||
* Delete a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($path);
|
||||
|
||||
/**
|
||||
* Delete a directory.
|
||||
*
|
||||
* @param string $dirname
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteDir($dirname);
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
*
|
||||
* @param string $dirname directory name
|
||||
* @param Config $config
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function createDir($dirname, Config $config);
|
||||
|
||||
/**
|
||||
* Set the visibility for a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $visibility
|
||||
*
|
||||
* @return array|false file meta data
|
||||
*/
|
||||
public function setVisibility($path, $visibility);
|
||||
}
|
||||
30
vendor/league/flysystem/src/CalculateChecksumFromStream.php
vendored
Normal file
30
vendor/league/flysystem/src/CalculateChecksumFromStream.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use function hash_final;
|
||||
use function hash_init;
|
||||
use function hash_update_stream;
|
||||
|
||||
trait CalculateChecksumFromStream
|
||||
{
|
||||
private function calculateChecksumFromStream(string $path, Config $config): string
|
||||
{
|
||||
try {
|
||||
$stream = $this->readStream($path);
|
||||
$algo = (string) $config->get('checksum_algo', 'md5');
|
||||
$context = hash_init($algo);
|
||||
hash_update_stream($context, $stream);
|
||||
|
||||
return hash_final($context);
|
||||
} catch (FilesystemException $exception) {
|
||||
throw new UnableToProvideChecksum($exception->getMessage(), $path, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*/
|
||||
abstract public function readStream(string $path);
|
||||
}
|
||||
11
vendor/league/flysystem/src/ChecksumAlgoIsNotSupported.php
vendored
Normal file
11
vendor/league/flysystem/src/ChecksumAlgoIsNotSupported.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class ChecksumAlgoIsNotSupported extends InvalidArgumentException
|
||||
{
|
||||
|
||||
}
|
||||
14
vendor/league/flysystem/src/ChecksumProvider.php
vendored
Normal file
14
vendor/league/flysystem/src/ChecksumProvider.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface ChecksumProvider
|
||||
{
|
||||
/**
|
||||
* @return string MD5 hash of the file contents
|
||||
*
|
||||
* @throws UnableToProvideChecksum
|
||||
* @throws ChecksumAlgoIsNotSupported
|
||||
*/
|
||||
public function checksum(string $path, Config $config): string;
|
||||
}
|
||||
100
vendor/league/flysystem/src/Config.php
vendored
100
vendor/league/flysystem/src/Config.php
vendored
@@ -1,107 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use function array_merge;
|
||||
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings = [];
|
||||
public const OPTION_VISIBILITY = 'visibility';
|
||||
public const OPTION_DIRECTORY_VISIBILITY = 'directory_visibility';
|
||||
|
||||
/**
|
||||
* @var Config|null
|
||||
*/
|
||||
protected $fallback;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $settings
|
||||
*/
|
||||
public function __construct(array $settings = [])
|
||||
public function __construct(private array $options = [])
|
||||
{
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a setting.
|
||||
* @param mixed $default
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed config setting or default when not found
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
public function get(string $property, $default = null)
|
||||
{
|
||||
if ( ! array_key_exists($key, $this->settings)) {
|
||||
return $this->getDefault($key, $default);
|
||||
}
|
||||
|
||||
return $this->settings[$key];
|
||||
return $this->options[$property] ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an item exists by key.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key)
|
||||
public function extend(array $options): Config
|
||||
{
|
||||
if (array_key_exists($key, $this->settings)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->fallback instanceof Config
|
||||
? $this->fallback->has($key)
|
||||
: false;
|
||||
return new Config(array_merge($this->options, $options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to retrieve a default setting from a config fallback.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed config setting or default when not found
|
||||
*/
|
||||
protected function getDefault($key, $default)
|
||||
public function withDefaults(array $defaults): Config
|
||||
{
|
||||
if ( ! $this->fallback) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $this->fallback->get($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a setting.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->settings[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fallback.
|
||||
*
|
||||
* @param Config $fallback
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFallback(Config $fallback)
|
||||
{
|
||||
$this->fallback = $fallback;
|
||||
|
||||
return $this;
|
||||
return new Config($this->options + $defaults);
|
||||
}
|
||||
}
|
||||
|
||||
49
vendor/league/flysystem/src/ConfigAwareTrait.php
vendored
49
vendor/league/flysystem/src/ConfigAwareTrait.php
vendored
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
trait ConfigAwareTrait
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Set the config.
|
||||
*
|
||||
* @param Config|array|null $config
|
||||
*/
|
||||
protected function setConfig($config)
|
||||
{
|
||||
$this->config = $config ? Util::ensureConfig($config) : new Config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Config.
|
||||
*
|
||||
* @return Config config object
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a config array to a Config object with the correct fallback.
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @return Config
|
||||
*/
|
||||
protected function prepareConfig(array $config)
|
||||
{
|
||||
$config = new Config($config);
|
||||
$config->setFallback($this->getConfig());
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class ConnectionErrorException extends ErrorException implements FilesystemException
|
||||
{
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class ConnectionRuntimeException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
}
|
||||
@@ -2,15 +2,11 @@
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use LogicException;
|
||||
use RuntimeException;
|
||||
|
||||
class CorruptedPathDetected extends LogicException implements FilesystemException
|
||||
final class CorruptedPathDetected extends RuntimeException implements FilesystemException
|
||||
{
|
||||
/**
|
||||
* @param string $path
|
||||
* @return CorruptedPathDetected
|
||||
*/
|
||||
public static function forPath($path)
|
||||
public static function forPath(string $path): CorruptedPathDetected
|
||||
{
|
||||
return new CorruptedPathDetected("Corrupted path detected: " . $path);
|
||||
}
|
||||
|
||||
31
vendor/league/flysystem/src/Directory.php
vendored
31
vendor/league/flysystem/src/Directory.php
vendored
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class Directory extends Handler
|
||||
{
|
||||
/**
|
||||
* Delete the directory.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
return $this->filesystem->deleteDir($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the directory contents.
|
||||
*
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return array|bool directory contents or false
|
||||
*/
|
||||
public function getContents($recursive = false)
|
||||
{
|
||||
return $this->filesystem->listContents($this->path, $recursive);
|
||||
}
|
||||
}
|
||||
87
vendor/league/flysystem/src/DirectoryAttributes.php
vendored
Normal file
87
vendor/league/flysystem/src/DirectoryAttributes.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
class DirectoryAttributes implements StorageAttributes
|
||||
{
|
||||
use ProxyArrayAccessToProperties;
|
||||
private string $type = StorageAttributes::TYPE_DIRECTORY;
|
||||
|
||||
public function __construct(
|
||||
private string $path,
|
||||
private ?string $visibility = null,
|
||||
private ?int $lastModified = null,
|
||||
private array $extraMetadata = [])
|
||||
{
|
||||
$this->path = trim($this->path, '/');
|
||||
}
|
||||
|
||||
public function path(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function type(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function visibility(): ?string
|
||||
{
|
||||
return $this->visibility;
|
||||
}
|
||||
|
||||
public function lastModified(): ?int
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
public function extraMetadata(): array
|
||||
{
|
||||
return $this->extraMetadata;
|
||||
}
|
||||
|
||||
public function isFile(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isDir(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function withPath(string $path): self
|
||||
{
|
||||
$clone = clone $this;
|
||||
$clone->path = $path;
|
||||
|
||||
return $clone;
|
||||
}
|
||||
|
||||
public static function fromArray(array $attributes): self
|
||||
{
|
||||
return new DirectoryAttributes(
|
||||
$attributes[StorageAttributes::ATTRIBUTE_PATH],
|
||||
$attributes[StorageAttributes::ATTRIBUTE_VISIBILITY] ?? null,
|
||||
$attributes[StorageAttributes::ATTRIBUTE_LAST_MODIFIED] ?? null,
|
||||
$attributes[StorageAttributes::ATTRIBUTE_EXTRA_METADATA] ?? []
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
StorageAttributes::ATTRIBUTE_TYPE => $this->type,
|
||||
StorageAttributes::ATTRIBUTE_PATH => $this->path,
|
||||
StorageAttributes::ATTRIBUTE_VISIBILITY => $this->visibility,
|
||||
StorageAttributes::ATTRIBUTE_LAST_MODIFIED => $this->lastModified,
|
||||
StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata,
|
||||
];
|
||||
}
|
||||
}
|
||||
78
vendor/league/flysystem/src/DirectoryListing.php
vendored
Normal file
78
vendor/league/flysystem/src/DirectoryListing.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use ArrayIterator;
|
||||
use Generator;
|
||||
use IteratorAggregate;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class DirectoryListing implements IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @param iterable<T> $listing
|
||||
*/
|
||||
public function __construct(private iterable $listing)
|
||||
{
|
||||
}
|
||||
|
||||
public function filter(callable $filter): DirectoryListing
|
||||
{
|
||||
$generator = (static function (iterable $listing) use ($filter): Generator {
|
||||
foreach ($listing as $item) {
|
||||
if ($filter($item)) {
|
||||
yield $item;
|
||||
}
|
||||
}
|
||||
})($this->listing);
|
||||
|
||||
return new DirectoryListing($generator);
|
||||
}
|
||||
|
||||
public function map(callable $mapper): DirectoryListing
|
||||
{
|
||||
$generator = (static function (iterable $listing) use ($mapper): Generator {
|
||||
foreach ($listing as $item) {
|
||||
yield $mapper($item);
|
||||
}
|
||||
})($this->listing);
|
||||
|
||||
return new DirectoryListing($generator);
|
||||
}
|
||||
|
||||
public function sortByPath(): DirectoryListing
|
||||
{
|
||||
$listing = $this->toArray();
|
||||
|
||||
usort($listing, function (StorageAttributes $a, StorageAttributes $b) {
|
||||
return $a->path() <=> $b->path();
|
||||
});
|
||||
|
||||
return new DirectoryListing($listing);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Traversable<T>
|
||||
*/
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
return $this->listing instanceof Traversable
|
||||
? $this->listing
|
||||
: new ArrayIterator($this->listing);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->listing instanceof Traversable
|
||||
? iterator_to_array($this->listing, false)
|
||||
: (array) $this->listing;
|
||||
}
|
||||
}
|
||||
8
vendor/league/flysystem/src/Exception.php
vendored
8
vendor/league/flysystem/src/Exception.php
vendored
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
class Exception extends \Exception implements FilesystemException
|
||||
{
|
||||
//
|
||||
}
|
||||
205
vendor/league/flysystem/src/File.php
vendored
205
vendor/league/flysystem/src/File.php
vendored
@@ -1,205 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class File extends Handler
|
||||
{
|
||||
/**
|
||||
* Check whether the file exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exists()
|
||||
{
|
||||
return $this->filesystem->has($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the file.
|
||||
*
|
||||
* @return string|false file contents
|
||||
*/
|
||||
public function read()
|
||||
{
|
||||
return $this->filesystem->read($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the file as a stream.
|
||||
*
|
||||
* @return resource|false file stream
|
||||
*/
|
||||
public function readStream()
|
||||
{
|
||||
return $this->filesystem->readStream($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the new file.
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return bool success boolean
|
||||
*/
|
||||
public function write($content)
|
||||
{
|
||||
return $this->filesystem->write($this->path, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the new file using a stream.
|
||||
*
|
||||
* @param resource $resource
|
||||
*
|
||||
* @return bool success boolean
|
||||
*/
|
||||
public function writeStream($resource)
|
||||
{
|
||||
return $this->filesystem->writeStream($this->path, $resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the file contents.
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return bool success boolean
|
||||
*/
|
||||
public function update($content)
|
||||
{
|
||||
return $this->filesystem->update($this->path, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the file contents with a stream.
|
||||
*
|
||||
* @param resource $resource
|
||||
*
|
||||
* @return bool success boolean
|
||||
*/
|
||||
public function updateStream($resource)
|
||||
{
|
||||
return $this->filesystem->updateStream($this->path, $resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the file or update if exists.
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return bool success boolean
|
||||
*/
|
||||
public function put($content)
|
||||
{
|
||||
return $this->filesystem->put($this->path, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the file or update if exists using a stream.
|
||||
*
|
||||
* @param resource $resource
|
||||
*
|
||||
* @return bool success boolean
|
||||
*/
|
||||
public function putStream($resource)
|
||||
{
|
||||
return $this->filesystem->putStream($this->path, $resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the file.
|
||||
*
|
||||
* @param string $newpath
|
||||
*
|
||||
* @return bool success boolean
|
||||
*/
|
||||
public function rename($newpath)
|
||||
{
|
||||
if ($this->filesystem->rename($this->path, $newpath)) {
|
||||
$this->path = $newpath;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the file.
|
||||
*
|
||||
* @param string $newpath
|
||||
*
|
||||
* @return File|false new file or false
|
||||
*/
|
||||
public function copy($newpath)
|
||||
{
|
||||
if ($this->filesystem->copy($this->path, $newpath)) {
|
||||
return new File($this->filesystem, $newpath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's timestamp.
|
||||
*
|
||||
* @return string|false The timestamp or false on failure.
|
||||
*/
|
||||
public function getTimestamp()
|
||||
{
|
||||
return $this->filesystem->getTimestamp($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's mimetype.
|
||||
*
|
||||
* @return string|false The file mime-type or false on failure.
|
||||
*/
|
||||
public function getMimetype()
|
||||
{
|
||||
return $this->filesystem->getMimetype($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's visibility.
|
||||
*
|
||||
* @return string|false The visibility (public|private) or false on failure.
|
||||
*/
|
||||
public function getVisibility()
|
||||
{
|
||||
return $this->filesystem->getVisibility($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's metadata.
|
||||
*
|
||||
* @return array|false The file metadata or false on failure.
|
||||
*/
|
||||
public function getMetadata()
|
||||
{
|
||||
return $this->filesystem->getMetadata($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file size.
|
||||
*
|
||||
* @return int|false The file size or false on failure.
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->filesystem->getSize($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the file.
|
||||
*
|
||||
* @return bool success boolean
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
return $this->filesystem->delete($this->path);
|
||||
}
|
||||
}
|
||||
100
vendor/league/flysystem/src/FileAttributes.php
vendored
Normal file
100
vendor/league/flysystem/src/FileAttributes.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
class FileAttributes implements StorageAttributes
|
||||
{
|
||||
use ProxyArrayAccessToProperties;
|
||||
private string $type = StorageAttributes::TYPE_FILE;
|
||||
|
||||
public function __construct(
|
||||
private string $path,
|
||||
private ?int $fileSize = null,
|
||||
private ?string $visibility = null,
|
||||
private ?int $lastModified = null,
|
||||
private ?string $mimeType = null,
|
||||
private array $extraMetadata = []
|
||||
) {
|
||||
$this->path = ltrim($this->path, '/');
|
||||
}
|
||||
|
||||
public function type(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function path(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function fileSize(): ?int
|
||||
{
|
||||
return $this->fileSize;
|
||||
}
|
||||
|
||||
public function visibility(): ?string
|
||||
{
|
||||
return $this->visibility;
|
||||
}
|
||||
|
||||
public function lastModified(): ?int
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
public function mimeType(): ?string
|
||||
{
|
||||
return $this->mimeType;
|
||||
}
|
||||
|
||||
public function extraMetadata(): array
|
||||
{
|
||||
return $this->extraMetadata;
|
||||
}
|
||||
|
||||
public function isFile(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isDir(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function withPath(string $path): self
|
||||
{
|
||||
$clone = clone $this;
|
||||
$clone->path = $path;
|
||||
|
||||
return $clone;
|
||||
}
|
||||
|
||||
public static function fromArray(array $attributes): self
|
||||
{
|
||||
return new FileAttributes(
|
||||
$attributes[StorageAttributes::ATTRIBUTE_PATH],
|
||||
$attributes[StorageAttributes::ATTRIBUTE_FILE_SIZE] ?? null,
|
||||
$attributes[StorageAttributes::ATTRIBUTE_VISIBILITY] ?? null,
|
||||
$attributes[StorageAttributes::ATTRIBUTE_LAST_MODIFIED] ?? null,
|
||||
$attributes[StorageAttributes::ATTRIBUTE_MIME_TYPE] ?? null,
|
||||
$attributes[StorageAttributes::ATTRIBUTE_EXTRA_METADATA] ?? []
|
||||
);
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
StorageAttributes::ATTRIBUTE_TYPE => self::TYPE_FILE,
|
||||
StorageAttributes::ATTRIBUTE_PATH => $this->path,
|
||||
StorageAttributes::ATTRIBUTE_FILE_SIZE => $this->fileSize,
|
||||
StorageAttributes::ATTRIBUTE_VISIBILITY => $this->visibility,
|
||||
StorageAttributes::ATTRIBUTE_LAST_MODIFIED => $this->lastModified,
|
||||
StorageAttributes::ATTRIBUTE_MIME_TYPE => $this->mimeType,
|
||||
StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use Exception as BaseException;
|
||||
|
||||
class FileExistsException extends Exception
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $code
|
||||
* @param BaseException $previous
|
||||
*/
|
||||
public function __construct($path, $code = 0, BaseException $previous = null)
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
parent::__construct('File already exists at path: ' . $this->getPath(), $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path which was found.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use Exception as BaseException;
|
||||
|
||||
class FileNotFoundException extends Exception
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $code
|
||||
* @param \Exception $previous
|
||||
*/
|
||||
public function __construct($path, $code = 0, BaseException $previous = null)
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
parent::__construct('File not found at path: ' . $this->getPath(), $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path which was not found.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
}
|
||||
548
vendor/league/flysystem/src/Filesystem.php
vendored
548
vendor/league/flysystem/src/Filesystem.php
vendored
@@ -1,409 +1,239 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use League\Flysystem\Adapter\CanOverwriteFiles;
|
||||
use League\Flysystem\Plugin\PluggableTrait;
|
||||
use League\Flysystem\Util\ContentListingFormatter;
|
||||
use DateTimeInterface;
|
||||
use Generator;
|
||||
use League\Flysystem\UrlGeneration\ShardedPrefixPublicUrlGenerator;
|
||||
use League\Flysystem\UrlGeneration\PrefixPublicUrlGenerator;
|
||||
use League\Flysystem\UrlGeneration\PublicUrlGenerator;
|
||||
use League\Flysystem\UrlGeneration\TemporaryUrlGenerator;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* @method void emptyDir(string $dirname)
|
||||
* @method array|false getWithMetadata(string $path, string[] $metadata)
|
||||
* @method bool forceCopy(string $path, string $newpath)
|
||||
* @method bool forceRename(string $path, string $newpath)
|
||||
* @method array listFiles(string $path = '', boolean $recursive = false)
|
||||
* @method string[] listPaths(string $path = '', boolean $recursive = false)
|
||||
* @method array listWith(string[] $keys = [], $directory = '', $recursive = false)
|
||||
*/
|
||||
class Filesystem implements FilesystemInterface
|
||||
use function is_array;
|
||||
|
||||
class Filesystem implements FilesystemOperator
|
||||
{
|
||||
use PluggableTrait;
|
||||
use ConfigAwareTrait;
|
||||
use CalculateChecksumFromStream;
|
||||
|
||||
/**
|
||||
* @var AdapterInterface
|
||||
*/
|
||||
protected $adapter;
|
||||
private Config $config;
|
||||
private PathNormalizer $pathNormalizer;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param AdapterInterface $adapter
|
||||
* @param Config|array $config
|
||||
*/
|
||||
public function __construct(AdapterInterface $adapter, $config = null)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
$this->setConfig($config);
|
||||
public function __construct(
|
||||
private FilesystemAdapter $adapter,
|
||||
array $config = [],
|
||||
PathNormalizer $pathNormalizer = null,
|
||||
private ?PublicUrlGenerator $publicUrlGenerator = null,
|
||||
private ?TemporaryUrlGenerator $temporaryUrlGenerator = null,
|
||||
) {
|
||||
$this->config = new Config($config);
|
||||
$this->pathNormalizer = $pathNormalizer ?: new WhitespacePathNormalizer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Adapter.
|
||||
*
|
||||
* @return AdapterInterface adapter
|
||||
*/
|
||||
public function getAdapter()
|
||||
public function fileExists(string $location): bool
|
||||
{
|
||||
return $this->adapter;
|
||||
return $this->adapter->fileExists($this->pathNormalizer->normalizePath($location));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function has($path)
|
||||
public function directoryExists(string $location): bool
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
|
||||
return strlen($path) === 0 ? false : (bool) $this->getAdapter()->has($path);
|
||||
return $this->adapter->directoryExists($this->pathNormalizer->normalizePath($location));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function write($path, $contents, array $config = [])
|
||||
public function has(string $location): bool
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertAbsent($path);
|
||||
$config = $this->prepareConfig($config);
|
||||
$path = $this->pathNormalizer->normalizePath($location);
|
||||
|
||||
return (bool) $this->getAdapter()->write($path, $contents, $config);
|
||||
return $this->adapter->fileExists($path) || $this->adapter->directoryExists($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function writeStream($path, $resource, array $config = [])
|
||||
public function write(string $location, string $contents, array $config = []): void
|
||||
{
|
||||
if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') {
|
||||
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
|
||||
$this->adapter->write(
|
||||
$this->pathNormalizer->normalizePath($location),
|
||||
$contents,
|
||||
$this->config->extend($config)
|
||||
);
|
||||
}
|
||||
|
||||
public function writeStream(string $location, $contents, array $config = []): void
|
||||
{
|
||||
/* @var resource $contents */
|
||||
$this->assertIsResource($contents);
|
||||
$this->rewindStream($contents);
|
||||
$this->adapter->writeStream(
|
||||
$this->pathNormalizer->normalizePath($location),
|
||||
$contents,
|
||||
$this->config->extend($config)
|
||||
);
|
||||
}
|
||||
|
||||
public function read(string $location): string
|
||||
{
|
||||
return $this->adapter->read($this->pathNormalizer->normalizePath($location));
|
||||
}
|
||||
|
||||
public function readStream(string $location)
|
||||
{
|
||||
return $this->adapter->readStream($this->pathNormalizer->normalizePath($location));
|
||||
}
|
||||
|
||||
public function delete(string $location): void
|
||||
{
|
||||
$this->adapter->delete($this->pathNormalizer->normalizePath($location));
|
||||
}
|
||||
|
||||
public function deleteDirectory(string $location): void
|
||||
{
|
||||
$this->adapter->deleteDirectory($this->pathNormalizer->normalizePath($location));
|
||||
}
|
||||
|
||||
public function createDirectory(string $location, array $config = []): void
|
||||
{
|
||||
$this->adapter->createDirectory(
|
||||
$this->pathNormalizer->normalizePath($location),
|
||||
$this->config->extend($config)
|
||||
);
|
||||
}
|
||||
|
||||
public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing
|
||||
{
|
||||
$path = $this->pathNormalizer->normalizePath($location);
|
||||
$listing = $this->adapter->listContents($path, $deep);
|
||||
|
||||
return new DirectoryListing($this->pipeListing($location, $deep, $listing));
|
||||
}
|
||||
|
||||
private function pipeListing(string $location, bool $deep, iterable $listing): Generator
|
||||
{
|
||||
try {
|
||||
foreach ($listing as $item) {
|
||||
yield $item;
|
||||
}
|
||||
} catch (Throwable $exception) {
|
||||
throw UnableToListContents::atLocation($location, $deep, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
public function move(string $source, string $destination, array $config = []): void
|
||||
{
|
||||
$this->adapter->move(
|
||||
$this->pathNormalizer->normalizePath($source),
|
||||
$this->pathNormalizer->normalizePath($destination),
|
||||
$this->config->extend($config)
|
||||
);
|
||||
}
|
||||
|
||||
public function copy(string $source, string $destination, array $config = []): void
|
||||
{
|
||||
$this->adapter->copy(
|
||||
$this->pathNormalizer->normalizePath($source),
|
||||
$this->pathNormalizer->normalizePath($destination),
|
||||
$this->config->extend($config)
|
||||
);
|
||||
}
|
||||
|
||||
public function lastModified(string $path): int
|
||||
{
|
||||
return $this->adapter->lastModified($this->pathNormalizer->normalizePath($path))->lastModified();
|
||||
}
|
||||
|
||||
public function fileSize(string $path): int
|
||||
{
|
||||
return $this->adapter->fileSize($this->pathNormalizer->normalizePath($path))->fileSize();
|
||||
}
|
||||
|
||||
public function mimeType(string $path): string
|
||||
{
|
||||
return $this->adapter->mimeType($this->pathNormalizer->normalizePath($path))->mimeType();
|
||||
}
|
||||
|
||||
public function setVisibility(string $path, string $visibility): void
|
||||
{
|
||||
$this->adapter->setVisibility($this->pathNormalizer->normalizePath($path), $visibility);
|
||||
}
|
||||
|
||||
public function visibility(string $path): string
|
||||
{
|
||||
return $this->adapter->visibility($this->pathNormalizer->normalizePath($path))->visibility();
|
||||
}
|
||||
|
||||
public function publicUrl(string $path, array $config = []): string
|
||||
{
|
||||
$this->publicUrlGenerator ??= $this->resolvePublicUrlGenerator()
|
||||
?: throw UnableToGeneratePublicUrl::noGeneratorConfigured($path);
|
||||
$config = $this->config->extend($config);
|
||||
|
||||
return $this->publicUrlGenerator->publicUrl($path, $config);
|
||||
}
|
||||
|
||||
public function temporaryUrl(string $path, DateTimeInterface $expiresAt, array $config = []): string
|
||||
{
|
||||
$generator = $this->temporaryUrlGenerator ?: $this->adapter;
|
||||
|
||||
if ($generator instanceof TemporaryUrlGenerator) {
|
||||
return $generator->temporaryUrl($path, $expiresAt, $this->config->extend($config));
|
||||
}
|
||||
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertAbsent($path);
|
||||
$config = $this->prepareConfig($config);
|
||||
|
||||
Util::rewindStream($resource);
|
||||
|
||||
return (bool) $this->getAdapter()->writeStream($path, $resource, $config);
|
||||
throw UnableToGenerateTemporaryUrl::noGeneratorConfigured($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function put($path, $contents, array $config = [])
|
||||
public function checksum(string $path, array $config = []): string
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$config = $this->prepareConfig($config);
|
||||
$config = $this->config->extend($config);
|
||||
|
||||
if ( ! $this->getAdapter() instanceof CanOverwriteFiles && $this->has($path)) {
|
||||
return (bool) $this->getAdapter()->update($path, $contents, $config);
|
||||
if ( ! $this->adapter instanceof ChecksumProvider) {
|
||||
return $this->calculateChecksumFromStream($path, $config);
|
||||
}
|
||||
|
||||
return (bool) $this->getAdapter()->write($path, $contents, $config);
|
||||
try {
|
||||
return $this->adapter->checksum($path, $config);
|
||||
} catch (ChecksumAlgoIsNotSupported) {
|
||||
return $this->calculateChecksumFromStream($path, $config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function putStream($path, $resource, array $config = [])
|
||||
private function resolvePublicUrlGenerator(): ?PublicUrlGenerator
|
||||
{
|
||||
if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') {
|
||||
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
|
||||
if ($publicUrl = $this->config->get('public_url')) {
|
||||
return match (true) {
|
||||
is_array($publicUrl) => new ShardedPrefixPublicUrlGenerator($publicUrl),
|
||||
default => new PrefixPublicUrlGenerator($publicUrl),
|
||||
};
|
||||
}
|
||||
|
||||
$path = Util::normalizePath($path);
|
||||
$config = $this->prepareConfig($config);
|
||||
Util::rewindStream($resource);
|
||||
|
||||
if ( ! $this->getAdapter() instanceof CanOverwriteFiles && $this->has($path)) {
|
||||
return (bool) $this->getAdapter()->updateStream($path, $resource, $config);
|
||||
if ($this->adapter instanceof PublicUrlGenerator) {
|
||||
return $this->adapter;
|
||||
}
|
||||
|
||||
return (bool) $this->getAdapter()->writeStream($path, $resource, $config);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @param mixed $contents
|
||||
*/
|
||||
public function readAndDelete($path)
|
||||
private function assertIsResource($contents): void
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
$contents = $this->read($path);
|
||||
|
||||
if ($contents === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->delete($path);
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function update($path, $contents, array $config = [])
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$config = $this->prepareConfig($config);
|
||||
|
||||
$this->assertPresent($path);
|
||||
|
||||
return (bool) $this->getAdapter()->update($path, $contents, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function updateStream($path, $resource, array $config = [])
|
||||
{
|
||||
if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') {
|
||||
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
|
||||
}
|
||||
|
||||
$path = Util::normalizePath($path);
|
||||
$config = $this->prepareConfig($config);
|
||||
$this->assertPresent($path);
|
||||
Util::rewindStream($resource);
|
||||
|
||||
return (bool) $this->getAdapter()->updateStream($path, $resource, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function read($path)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
if ( ! ($object = $this->getAdapter()->read($path))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $object['contents'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function readStream($path)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
if ( ! $object = $this->getAdapter()->readStream($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $object['stream'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rename($path, $newpath)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$newpath = Util::normalizePath($newpath);
|
||||
$this->assertPresent($path);
|
||||
$this->assertAbsent($newpath);
|
||||
|
||||
return (bool) $this->getAdapter()->rename($path, $newpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function copy($path, $newpath)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$newpath = Util::normalizePath($newpath);
|
||||
$this->assertPresent($path);
|
||||
$this->assertAbsent($newpath);
|
||||
|
||||
return $this->getAdapter()->copy($path, $newpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function delete($path)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
return $this->getAdapter()->delete($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function deleteDir($dirname)
|
||||
{
|
||||
$dirname = Util::normalizePath($dirname);
|
||||
|
||||
if ($dirname === '') {
|
||||
throw new RootViolationException('Root directories can not be deleted.');
|
||||
}
|
||||
|
||||
return (bool) $this->getAdapter()->deleteDir($dirname);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function createDir($dirname, array $config = [])
|
||||
{
|
||||
$dirname = Util::normalizePath($dirname);
|
||||
$config = $this->prepareConfig($config);
|
||||
|
||||
return (bool) $this->getAdapter()->createDir($dirname, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function listContents($directory = '', $recursive = false)
|
||||
{
|
||||
$directory = Util::normalizePath($directory);
|
||||
$contents = $this->getAdapter()->listContents($directory, $recursive);
|
||||
|
||||
return (new ContentListingFormatter($directory, $recursive, $this->config->get('case_sensitive', true)))
|
||||
->formatListing($contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMimetype($path)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
if (( ! $object = $this->getAdapter()->getMimetype($path)) || ! array_key_exists('mimetype', $object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $object['mimetype'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getTimestamp($path)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
if (( ! $object = $this->getAdapter()->getTimestamp($path)) || ! array_key_exists('timestamp', $object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (int) $object['timestamp'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getVisibility($path)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
if (( ! $object = $this->getAdapter()->getVisibility($path)) || ! array_key_exists('visibility', $object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $object['visibility'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getSize($path)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
if (( ! $object = $this->getAdapter()->getSize($path)) || ! array_key_exists('size', $object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (int) $object['size'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setVisibility($path, $visibility)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
return (bool) $this->getAdapter()->setVisibility($path, $visibility);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMetadata($path)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
$this->assertPresent($path);
|
||||
|
||||
return $this->getAdapter()->getMetadata($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get($path, Handler $handler = null)
|
||||
{
|
||||
$path = Util::normalizePath($path);
|
||||
|
||||
if ( ! $handler) {
|
||||
$metadata = $this->getMetadata($path);
|
||||
$handler = ($metadata && $metadata['type'] === 'file') ? new File($this, $path) : new Directory($this, $path);
|
||||
}
|
||||
|
||||
$handler->setPath($path);
|
||||
$handler->setFilesystem($this);
|
||||
|
||||
return $handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a file is present.
|
||||
*
|
||||
* @param string $path path to file
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertPresent($path)
|
||||
{
|
||||
if ($this->config->get('disable_asserts', false) === false && ! $this->has($path)) {
|
||||
throw new FileNotFoundException($path);
|
||||
if (is_resource($contents) === false) {
|
||||
throw new InvalidStreamProvided(
|
||||
"Invalid stream provided, expected stream resource, received " . gettype($contents)
|
||||
);
|
||||
} elseif ($type = get_resource_type($contents) !== 'stream') {
|
||||
throw new InvalidStreamProvided(
|
||||
"Invalid stream provided, expected stream resource, received resource of type " . $type
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a file is absent.
|
||||
*
|
||||
* @param string $path path to file
|
||||
*
|
||||
* @throws FileExistsException
|
||||
*
|
||||
* @return void
|
||||
* @param resource $resource
|
||||
*/
|
||||
public function assertAbsent($path)
|
||||
private function rewindStream($resource): void
|
||||
{
|
||||
if ($this->config->get('disable_asserts', false) === false && $this->has($path)) {
|
||||
throw new FileExistsException($path);
|
||||
if (ftell($resource) !== 0 && stream_get_meta_data($resource)['seekable']) {
|
||||
rewind($resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
115
vendor/league/flysystem/src/FilesystemAdapter.php
vendored
Normal file
115
vendor/league/flysystem/src/FilesystemAdapter.php
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface FilesystemAdapter
|
||||
{
|
||||
/**
|
||||
* @throws FilesystemException
|
||||
* @throws UnableToCheckExistence
|
||||
*/
|
||||
public function fileExists(string $path): bool;
|
||||
|
||||
/**
|
||||
* @throws FilesystemException
|
||||
* @throws UnableToCheckExistence
|
||||
*/
|
||||
public function directoryExists(string $path): bool;
|
||||
|
||||
/**
|
||||
* @throws UnableToWriteFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function write(string $path, string $contents, Config $config): void;
|
||||
|
||||
/**
|
||||
* @param resource $contents
|
||||
*
|
||||
* @throws UnableToWriteFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function writeStream(string $path, $contents, Config $config): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToReadFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function read(string $path): string;
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*
|
||||
* @throws UnableToReadFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function readStream(string $path);
|
||||
|
||||
/**
|
||||
* @throws UnableToDeleteFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function delete(string $path): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToDeleteDirectory
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function deleteDirectory(string $path): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToCreateDirectory
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function createDirectory(string $path, Config $config): void;
|
||||
|
||||
/**
|
||||
* @throws InvalidVisibilityProvided
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function setVisibility(string $path, string $visibility): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToRetrieveMetadata
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function visibility(string $path): FileAttributes;
|
||||
|
||||
/**
|
||||
* @throws UnableToRetrieveMetadata
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function mimeType(string $path): FileAttributes;
|
||||
|
||||
/**
|
||||
* @throws UnableToRetrieveMetadata
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function lastModified(string $path): FileAttributes;
|
||||
|
||||
/**
|
||||
* @throws UnableToRetrieveMetadata
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function fileSize(string $path): FileAttributes;
|
||||
|
||||
/**
|
||||
* @return iterable<StorageAttributes>
|
||||
*
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function listContents(string $path, bool $deep): iterable;
|
||||
|
||||
/**
|
||||
* @throws UnableToMoveFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function move(string $source, string $destination, Config $config): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToCopyFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function copy(string $source, string $destination, Config $config): void;
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface FilesystemException
|
||||
use Throwable;
|
||||
|
||||
interface FilesystemException extends Throwable
|
||||
{
|
||||
}
|
||||
|
||||
284
vendor/league/flysystem/src/FilesystemInterface.php
vendored
284
vendor/league/flysystem/src/FilesystemInterface.php
vendored
@@ -1,284 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
interface FilesystemInterface
|
||||
{
|
||||
/**
|
||||
* Check whether a file exists.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($path);
|
||||
|
||||
/**
|
||||
* Read a file.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return string|false The file contents or false on failure.
|
||||
*/
|
||||
public function read($path);
|
||||
|
||||
/**
|
||||
* Retrieves a read-stream for a path.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return resource|false The path resource or false on failure.
|
||||
*/
|
||||
public function readStream($path);
|
||||
|
||||
/**
|
||||
* List contents of a directory.
|
||||
*
|
||||
* @param string $directory The directory to list.
|
||||
* @param bool $recursive Whether to list recursively.
|
||||
*
|
||||
* @return array A list of file metadata.
|
||||
*/
|
||||
public function listContents($directory = '', $recursive = false);
|
||||
|
||||
/**
|
||||
* Get a file's metadata.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return array|false The file metadata or false on failure.
|
||||
*/
|
||||
public function getMetadata($path);
|
||||
|
||||
/**
|
||||
* Get a file's size.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return int|false The file size or false on failure.
|
||||
*/
|
||||
public function getSize($path);
|
||||
|
||||
/**
|
||||
* Get a file's mime-type.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return string|false The file mime-type or false on failure.
|
||||
*/
|
||||
public function getMimetype($path);
|
||||
|
||||
/**
|
||||
* Get a file's timestamp.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return int|false The timestamp or false on failure.
|
||||
*/
|
||||
public function getTimestamp($path);
|
||||
|
||||
/**
|
||||
* Get a file's visibility.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return string|false The visibility (public|private) or false on failure.
|
||||
*/
|
||||
public function getVisibility($path);
|
||||
|
||||
/**
|
||||
* Write a new file.
|
||||
*
|
||||
* @param string $path The path of the new file.
|
||||
* @param string $contents The file contents.
|
||||
* @param array $config An optional configuration array.
|
||||
*
|
||||
* @throws FileExistsException
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function write($path, $contents, array $config = []);
|
||||
|
||||
/**
|
||||
* Write a new file using a stream.
|
||||
*
|
||||
* @param string $path The path of the new file.
|
||||
* @param resource $resource The file handle.
|
||||
* @param array $config An optional configuration array.
|
||||
*
|
||||
* @throws InvalidArgumentException If $resource is not a file handle.
|
||||
* @throws FileExistsException
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function writeStream($path, $resource, array $config = []);
|
||||
|
||||
/**
|
||||
* Update an existing file.
|
||||
*
|
||||
* @param string $path The path of the existing file.
|
||||
* @param string $contents The file contents.
|
||||
* @param array $config An optional configuration array.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function update($path, $contents, array $config = []);
|
||||
|
||||
/**
|
||||
* Update an existing file using a stream.
|
||||
*
|
||||
* @param string $path The path of the existing file.
|
||||
* @param resource $resource The file handle.
|
||||
* @param array $config An optional configuration array.
|
||||
*
|
||||
* @throws InvalidArgumentException If $resource is not a file handle.
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function updateStream($path, $resource, array $config = []);
|
||||
|
||||
/**
|
||||
* Rename a file.
|
||||
*
|
||||
* @param string $path Path to the existing file.
|
||||
* @param string $newpath The new path of the file.
|
||||
*
|
||||
* @throws FileExistsException Thrown if $newpath exists.
|
||||
* @throws FileNotFoundException Thrown if $path does not exist.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function rename($path, $newpath);
|
||||
|
||||
/**
|
||||
* Copy a file.
|
||||
*
|
||||
* @param string $path Path to the existing file.
|
||||
* @param string $newpath The new path of the file.
|
||||
*
|
||||
* @throws FileExistsException Thrown if $newpath exists.
|
||||
* @throws FileNotFoundException Thrown if $path does not exist.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function copy($path, $newpath);
|
||||
|
||||
/**
|
||||
* Delete a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function delete($path);
|
||||
|
||||
/**
|
||||
* Delete a directory.
|
||||
*
|
||||
* @param string $dirname
|
||||
*
|
||||
* @throws RootViolationException Thrown if $dirname is empty.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function deleteDir($dirname);
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
*
|
||||
* @param string $dirname The name of the new directory.
|
||||
* @param array $config An optional configuration array.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function createDir($dirname, array $config = []);
|
||||
|
||||
/**
|
||||
* Set the visibility for a file.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
* @param string $visibility One of 'public' or 'private'.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function setVisibility($path, $visibility);
|
||||
|
||||
/**
|
||||
* Create a file or update if exists.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
* @param string $contents The file contents.
|
||||
* @param array $config An optional configuration array.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function put($path, $contents, array $config = []);
|
||||
|
||||
/**
|
||||
* Create a file or update if exists.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
* @param resource $resource The file handle.
|
||||
* @param array $config An optional configuration array.
|
||||
*
|
||||
* @throws InvalidArgumentException Thrown if $resource is not a resource.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function putStream($path, $resource, array $config = []);
|
||||
|
||||
/**
|
||||
* Read and delete a file.
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return string|false The file contents, or false on failure.
|
||||
*/
|
||||
public function readAndDelete($path);
|
||||
|
||||
/**
|
||||
* Get a file/directory handler.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @param string $path The path to the file.
|
||||
* @param Handler $handler An optional existing handler to populate.
|
||||
*
|
||||
* @return Handler Either a file or directory handler.
|
||||
*/
|
||||
public function get($path, Handler $handler = null);
|
||||
|
||||
/**
|
||||
* Register a plugin.
|
||||
*
|
||||
* @param PluginInterface $plugin The plugin to register.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addPlugin(PluginInterface $plugin);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* Thrown when the MountManager cannot find a filesystem.
|
||||
*/
|
||||
class FilesystemNotFoundException extends LogicException implements FilesystemException
|
||||
{
|
||||
}
|
||||
25
vendor/league/flysystem/src/FilesystemOperationFailed.php
vendored
Normal file
25
vendor/league/flysystem/src/FilesystemOperationFailed.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface FilesystemOperationFailed extends FilesystemException
|
||||
{
|
||||
public const OPERATION_WRITE = 'WRITE';
|
||||
public const OPERATION_UPDATE = 'UPDATE'; // not used
|
||||
public const OPERATION_EXISTENCE_CHECK = 'EXISTENCE_CHECK';
|
||||
public const OPERATION_DIRECTORY_EXISTS = 'DIRECTORY_EXISTS';
|
||||
public const OPERATION_FILE_EXISTS = 'FILE_EXISTS';
|
||||
public const OPERATION_CREATE_DIRECTORY = 'CREATE_DIRECTORY';
|
||||
public const OPERATION_DELETE = 'DELETE';
|
||||
public const OPERATION_DELETE_DIRECTORY = 'DELETE_DIRECTORY';
|
||||
public const OPERATION_MOVE = 'MOVE';
|
||||
public const OPERATION_RETRIEVE_METADATA = 'RETRIEVE_METADATA';
|
||||
public const OPERATION_COPY = 'COPY';
|
||||
public const OPERATION_READ = 'READ';
|
||||
public const OPERATION_SET_VISIBILITY = 'SET_VISIBILITY';
|
||||
public const OPERATION_LIST_CONTENTS = 'LIST_CONTENTS';
|
||||
|
||||
public function operation(): string;
|
||||
}
|
||||
9
vendor/league/flysystem/src/FilesystemOperator.php
vendored
Normal file
9
vendor/league/flysystem/src/FilesystemOperator.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface FilesystemOperator extends FilesystemReader, FilesystemWriter
|
||||
{
|
||||
}
|
||||
85
vendor/league/flysystem/src/FilesystemReader.php
vendored
Normal file
85
vendor/league/flysystem/src/FilesystemReader.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use DateTimeInterface;
|
||||
|
||||
/**
|
||||
* This interface contains everything to read from and inspect
|
||||
* a filesystem. All methods containing are non-destructive.
|
||||
*
|
||||
* @method string publicUrl(string $path, array $config = []) Will be added in 4.0
|
||||
* @method string temporaryUrl(string $path, DateTimeInterface $expiresAt, array $config = []) Will be added in 4.0
|
||||
* @method string checksum(string $path, array $config = []) Will be added in 4.0
|
||||
*/
|
||||
interface FilesystemReader
|
||||
{
|
||||
public const LIST_SHALLOW = false;
|
||||
public const LIST_DEEP = true;
|
||||
|
||||
/**
|
||||
* @throws FilesystemException
|
||||
* @throws UnableToCheckExistence
|
||||
*/
|
||||
public function fileExists(string $location): bool;
|
||||
|
||||
/**
|
||||
* @throws FilesystemException
|
||||
* @throws UnableToCheckExistence
|
||||
*/
|
||||
public function directoryExists(string $location): bool;
|
||||
|
||||
/**
|
||||
* @throws FilesystemException
|
||||
* @throws UnableToCheckExistence
|
||||
*/
|
||||
public function has(string $location): bool;
|
||||
|
||||
/**
|
||||
* @throws UnableToReadFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function read(string $location): string;
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*
|
||||
* @throws UnableToReadFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function readStream(string $location);
|
||||
|
||||
/**
|
||||
* @return DirectoryListing<StorageAttributes>
|
||||
*
|
||||
* @throws FilesystemException
|
||||
* @throws UnableToListContents
|
||||
*/
|
||||
public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing;
|
||||
|
||||
/**
|
||||
* @throws UnableToRetrieveMetadata
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function lastModified(string $path): int;
|
||||
|
||||
/**
|
||||
* @throws UnableToRetrieveMetadata
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function fileSize(string $path): int;
|
||||
|
||||
/**
|
||||
* @throws UnableToRetrieveMetadata
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function mimeType(string $path): string;
|
||||
|
||||
/**
|
||||
* @throws UnableToRetrieveMetadata
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function visibility(string $path): string;
|
||||
}
|
||||
58
vendor/league/flysystem/src/FilesystemWriter.php
vendored
Normal file
58
vendor/league/flysystem/src/FilesystemWriter.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface FilesystemWriter
|
||||
{
|
||||
/**
|
||||
* @throws UnableToWriteFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function write(string $location, string $contents, array $config = []): void;
|
||||
|
||||
/**
|
||||
* @param mixed $contents
|
||||
*
|
||||
* @throws UnableToWriteFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function writeStream(string $location, $contents, array $config = []): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToSetVisibility
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function setVisibility(string $path, string $visibility): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToDeleteFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function delete(string $location): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToDeleteDirectory
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function deleteDirectory(string $location): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToCreateDirectory
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function createDirectory(string $location, array $config = []): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToMoveFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function move(string $source, string $destination, array $config = []): void;
|
||||
|
||||
/**
|
||||
* @throws UnableToCopyFile
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function copy(string $source, string $destination, array $config = []): void;
|
||||
}
|
||||
137
vendor/league/flysystem/src/Handler.php
vendored
137
vendor/league/flysystem/src/Handler.php
vendored
@@ -1,137 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use BadMethodCallException;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
abstract class Handler
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @var FilesystemInterface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param FilesystemInterface $filesystem
|
||||
* @param string $path
|
||||
*/
|
||||
public function __construct(FilesystemInterface $filesystem = null, $path = null)
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the entree is a directory.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDir()
|
||||
{
|
||||
return $this->getType() === 'dir';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the entree is a file.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFile()
|
||||
{
|
||||
return $this->getType() === 'file';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the entree type (file|dir).
|
||||
*
|
||||
* @return string file or dir
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
$metadata = $this->filesystem->getMetadata($this->path);
|
||||
|
||||
return $metadata ? $metadata['type'] : 'dir';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Filesystem object.
|
||||
*
|
||||
* @param FilesystemInterface $filesystem
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilesystem(FilesystemInterface $filesystem)
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Filesystem object.
|
||||
*
|
||||
* @return FilesystemInterface
|
||||
*/
|
||||
public function getFilesystem()
|
||||
{
|
||||
return $this->filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the entree path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the entree path.
|
||||
*
|
||||
* @return string path
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugins pass-through.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, array $arguments)
|
||||
{
|
||||
array_unshift($arguments, $this->path);
|
||||
$callback = [$this->filesystem, $method];
|
||||
|
||||
try {
|
||||
return call_user_func_array($callback, $arguments);
|
||||
} catch (BadMethodCallException $e) {
|
||||
throw new BadMethodCallException(
|
||||
'Call to undefined method '
|
||||
. get_called_class()
|
||||
. '::' . $method
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class InvalidRootException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
}
|
||||
11
vendor/league/flysystem/src/InvalidStreamProvided.php
vendored
Normal file
11
vendor/league/flysystem/src/InvalidStreamProvided.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidStreamProvided extends BaseInvalidArgumentException implements FilesystemException
|
||||
{
|
||||
}
|
||||
20
vendor/league/flysystem/src/InvalidVisibilityProvided.php
vendored
Normal file
20
vendor/league/flysystem/src/InvalidVisibilityProvided.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function var_export;
|
||||
|
||||
class InvalidVisibilityProvided extends InvalidArgumentException implements FilesystemException
|
||||
{
|
||||
public static function withVisibility(string $visibility, string $expectedMessage): InvalidVisibilityProvided
|
||||
{
|
||||
$provided = var_export($visibility, true);
|
||||
$message = "Invalid visibility provided. Expected {$expectedMessage}, received {$provided}";
|
||||
|
||||
throw new InvalidVisibilityProvided($message);
|
||||
}
|
||||
}
|
||||
51
vendor/league/flysystem/src/Local/FallbackMimeTypeDetector.php
vendored
Normal file
51
vendor/league/flysystem/src/Local/FallbackMimeTypeDetector.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\Local;
|
||||
|
||||
use League\MimeTypeDetection\MimeTypeDetector;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class FallbackMimeTypeDetector implements MimeTypeDetector
|
||||
{
|
||||
private const INCONCLUSIVE_MIME_TYPES = [
|
||||
'application/x-empty',
|
||||
'text/plain',
|
||||
'text/x-asm',
|
||||
'application/octet-stream',
|
||||
'inode/x-empty',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private MimeTypeDetector $detector,
|
||||
private array $inconclusiveMimetypes = self::INCONCLUSIVE_MIME_TYPES
|
||||
) {}
|
||||
|
||||
public function detectMimeType(string $path, $contents): ?string
|
||||
{
|
||||
return $this->detector->detectMimeType($path, $contents);
|
||||
}
|
||||
|
||||
public function detectMimeTypeFromBuffer(string $contents): ?string
|
||||
{
|
||||
return $this->detector->detectMimeTypeFromBuffer($contents);
|
||||
}
|
||||
|
||||
public function detectMimeTypeFromPath(string $path): ?string
|
||||
{
|
||||
return $this->detector->detectMimeTypeFromPath($path);
|
||||
}
|
||||
|
||||
public function detectMimeTypeFromFile(string $path): ?string
|
||||
{
|
||||
$mimeType = $this->detector->detectMimeTypeFromFile($path);
|
||||
|
||||
if ($mimeType !== null && ! in_array($mimeType, $this->inconclusiveMimetypes)) {
|
||||
return $mimeType;
|
||||
}
|
||||
|
||||
return $this->detector->detectMimeTypeFromPath($path);
|
||||
}
|
||||
}
|
||||
454
vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php
vendored
Normal file
454
vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php
vendored
Normal file
@@ -0,0 +1,454 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\Local;
|
||||
|
||||
use DirectoryIterator;
|
||||
use FilesystemIterator;
|
||||
use Generator;
|
||||
use League\Flysystem\ChecksumProvider;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\DirectoryAttributes;
|
||||
use League\Flysystem\FileAttributes;
|
||||
use League\Flysystem\FilesystemAdapter;
|
||||
use League\Flysystem\PathPrefixer;
|
||||
use League\Flysystem\SymbolicLinkEncountered;
|
||||
use League\Flysystem\UnableToCopyFile;
|
||||
use League\Flysystem\UnableToCreateDirectory;
|
||||
use League\Flysystem\UnableToDeleteDirectory;
|
||||
use League\Flysystem\UnableToDeleteFile;
|
||||
use League\Flysystem\UnableToMoveFile;
|
||||
use League\Flysystem\UnableToProvideChecksum;
|
||||
use League\Flysystem\UnableToReadFile;
|
||||
use League\Flysystem\UnableToRetrieveMetadata;
|
||||
use League\Flysystem\UnableToSetVisibility;
|
||||
use League\Flysystem\UnableToWriteFile;
|
||||
use League\Flysystem\UnixVisibility\PortableVisibilityConverter;
|
||||
use League\Flysystem\UnixVisibility\VisibilityConverter;
|
||||
use League\MimeTypeDetection\FinfoMimeTypeDetector;
|
||||
use League\MimeTypeDetection\MimeTypeDetector;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use SplFileInfo;
|
||||
use function chmod;
|
||||
use function clearstatcache;
|
||||
use function dirname;
|
||||
use function error_clear_last;
|
||||
use function error_get_last;
|
||||
use function file_exists;
|
||||
use function file_put_contents;
|
||||
use function hash_file;
|
||||
use function is_dir;
|
||||
use function is_file;
|
||||
use function mkdir;
|
||||
use function rename;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const LOCK_EX;
|
||||
|
||||
class LocalFilesystemAdapter implements FilesystemAdapter, ChecksumProvider
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public const SKIP_LINKS = 0001;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public const DISALLOW_LINKS = 0002;
|
||||
|
||||
private PathPrefixer $prefixer;
|
||||
private VisibilityConverter $visibility;
|
||||
private MimeTypeDetector $mimeTypeDetector;
|
||||
private string $rootLocation;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $rootLocationIsSetup = false;
|
||||
|
||||
public function __construct(
|
||||
string $location,
|
||||
VisibilityConverter $visibility = null,
|
||||
private int $writeFlags = LOCK_EX,
|
||||
private int $linkHandling = self::DISALLOW_LINKS,
|
||||
MimeTypeDetector $mimeTypeDetector = null,
|
||||
bool $lazyRootCreation = false,
|
||||
) {
|
||||
$this->prefixer = new PathPrefixer($location, DIRECTORY_SEPARATOR);
|
||||
$visibility ??= new PortableVisibilityConverter();
|
||||
$this->visibility = $visibility;
|
||||
$this->rootLocation = $location;
|
||||
$this->mimeTypeDetector = $mimeTypeDetector ?: new FallbackMimeTypeDetector(new FinfoMimeTypeDetector());
|
||||
|
||||
if ( ! $lazyRootCreation) {
|
||||
$this->ensureRootDirectoryExists();
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureRootDirectoryExists(): void
|
||||
{
|
||||
if ($this->rootLocationIsSetup) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->ensureDirectoryExists($this->rootLocation, $this->visibility->defaultForDirectories());
|
||||
}
|
||||
|
||||
public function write(string $path, string $contents, Config $config): void
|
||||
{
|
||||
$this->writeToFile($path, $contents, $config);
|
||||
}
|
||||
|
||||
public function writeStream(string $path, $contents, Config $config): void
|
||||
{
|
||||
$this->writeToFile($path, $contents, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource|string $contents
|
||||
*/
|
||||
private function writeToFile(string $path, $contents, Config $config): void
|
||||
{
|
||||
$prefixedLocation = $this->prefixer->prefixPath($path);
|
||||
$this->ensureRootDirectoryExists();
|
||||
$this->ensureDirectoryExists(
|
||||
dirname($prefixedLocation),
|
||||
$this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY))
|
||||
);
|
||||
error_clear_last();
|
||||
|
||||
if (@file_put_contents($prefixedLocation, $contents, $this->writeFlags) === false) {
|
||||
throw UnableToWriteFile::atLocation($path, error_get_last()['message'] ?? '');
|
||||
}
|
||||
|
||||
if ($visibility = $config->get(Config::OPTION_VISIBILITY)) {
|
||||
$this->setVisibility($path, (string) $visibility);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(string $path): void
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
|
||||
if ( ! file_exists($location)) {
|
||||
return;
|
||||
}
|
||||
|
||||
error_clear_last();
|
||||
|
||||
if ( ! @unlink($location)) {
|
||||
throw UnableToDeleteFile::atLocation($location, error_get_last()['message'] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteDirectory(string $prefix): void
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($prefix);
|
||||
|
||||
if ( ! is_dir($location)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$contents = $this->listDirectoryRecursively($location, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
/** @var SplFileInfo $file */
|
||||
foreach ($contents as $file) {
|
||||
if ( ! $this->deleteFileInfoObject($file)) {
|
||||
throw UnableToDeleteDirectory::atLocation($prefix, "Unable to delete file at " . $file->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
unset($contents);
|
||||
|
||||
if ( ! @rmdir($location)) {
|
||||
throw UnableToDeleteDirectory::atLocation($prefix, error_get_last()['message'] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
private function listDirectoryRecursively(
|
||||
string $path,
|
||||
int $mode = RecursiveIteratorIterator::SELF_FIRST
|
||||
): Generator {
|
||||
if ( ! is_dir($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield from new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
|
||||
$mode
|
||||
);
|
||||
}
|
||||
|
||||
protected function deleteFileInfoObject(SplFileInfo $file): bool
|
||||
{
|
||||
switch ($file->getType()) {
|
||||
case 'dir':
|
||||
return @rmdir((string) $file->getRealPath());
|
||||
case 'link':
|
||||
return @unlink((string) $file->getPathname());
|
||||
default:
|
||||
return @unlink((string) $file->getRealPath());
|
||||
}
|
||||
}
|
||||
|
||||
public function listContents(string $path, bool $deep): iterable
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
|
||||
if ( ! is_dir($location)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var SplFileInfo[] $iterator */
|
||||
$iterator = $deep ? $this->listDirectoryRecursively($location) : $this->listDirectory($location);
|
||||
|
||||
foreach ($iterator as $fileInfo) {
|
||||
if ($fileInfo->isLink()) {
|
||||
if ($this->linkHandling & self::SKIP_LINKS) {
|
||||
continue;
|
||||
}
|
||||
throw SymbolicLinkEncountered::atLocation($fileInfo->getPathname());
|
||||
}
|
||||
|
||||
$path = $this->prefixer->stripPrefix($fileInfo->getPathname());
|
||||
$lastModified = $fileInfo->getMTime();
|
||||
$isDirectory = $fileInfo->isDir();
|
||||
$permissions = octdec(substr(sprintf('%o', $fileInfo->getPerms()), -4));
|
||||
$visibility = $isDirectory ? $this->visibility->inverseForDirectory($permissions) : $this->visibility->inverseForFile($permissions);
|
||||
|
||||
yield $isDirectory ? new DirectoryAttributes(str_replace('\\', '/', $path), $visibility, $lastModified) : new FileAttributes(
|
||||
str_replace('\\', '/', $path),
|
||||
$fileInfo->getSize(),
|
||||
$visibility,
|
||||
$lastModified
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function move(string $source, string $destination, Config $config): void
|
||||
{
|
||||
$sourcePath = $this->prefixer->prefixPath($source);
|
||||
$destinationPath = $this->prefixer->prefixPath($destination);
|
||||
|
||||
$this->ensureRootDirectoryExists();
|
||||
$this->ensureDirectoryExists(
|
||||
dirname($destinationPath),
|
||||
$this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY))
|
||||
);
|
||||
|
||||
if ( ! @rename($sourcePath, $destinationPath)) {
|
||||
throw UnableToMoveFile::fromLocationTo($sourcePath, $destinationPath);
|
||||
}
|
||||
}
|
||||
|
||||
public function copy(string $source, string $destination, Config $config): void
|
||||
{
|
||||
$sourcePath = $this->prefixer->prefixPath($source);
|
||||
$destinationPath = $this->prefixer->prefixPath($destination);
|
||||
$this->ensureRootDirectoryExists();
|
||||
$this->ensureDirectoryExists(
|
||||
dirname($destinationPath),
|
||||
$this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY))
|
||||
);
|
||||
|
||||
if ( ! @copy($sourcePath, $destinationPath)) {
|
||||
throw UnableToCopyFile::fromLocationTo($sourcePath, $destinationPath);
|
||||
}
|
||||
}
|
||||
|
||||
public function read(string $path): string
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
error_clear_last();
|
||||
$contents = @file_get_contents($location);
|
||||
|
||||
if ($contents === false) {
|
||||
throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? '');
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
public function readStream(string $path)
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
error_clear_last();
|
||||
$contents = @fopen($location, 'rb');
|
||||
|
||||
if ($contents === false) {
|
||||
throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? '');
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
protected function ensureDirectoryExists(string $dirname, int $visibility): void
|
||||
{
|
||||
if (is_dir($dirname)) {
|
||||
return;
|
||||
}
|
||||
|
||||
error_clear_last();
|
||||
|
||||
if ( ! @mkdir($dirname, $visibility, true)) {
|
||||
$mkdirError = error_get_last();
|
||||
}
|
||||
|
||||
clearstatcache(true, $dirname);
|
||||
|
||||
if ( ! is_dir($dirname)) {
|
||||
$errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : '';
|
||||
|
||||
throw UnableToCreateDirectory::atLocation($dirname, $errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public function fileExists(string $location): bool
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($location);
|
||||
|
||||
return is_file($location);
|
||||
}
|
||||
|
||||
public function directoryExists(string $location): bool
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($location);
|
||||
|
||||
return is_dir($location);
|
||||
}
|
||||
|
||||
public function createDirectory(string $path, Config $config): void
|
||||
{
|
||||
$this->ensureRootDirectoryExists();
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
$visibility = $config->get(Config::OPTION_VISIBILITY, $config->get(Config::OPTION_DIRECTORY_VISIBILITY));
|
||||
$permissions = $this->resolveDirectoryVisibility($visibility);
|
||||
|
||||
if (is_dir($location)) {
|
||||
$this->setPermissions($location, $permissions);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
error_clear_last();
|
||||
|
||||
if ( ! @mkdir($location, $permissions, true)) {
|
||||
throw UnableToCreateDirectory::atLocation($path, error_get_last()['message'] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
public function setVisibility(string $path, string $visibility): void
|
||||
{
|
||||
$path = $this->prefixer->prefixPath($path);
|
||||
$visibility = is_dir($path) ? $this->visibility->forDirectory($visibility) : $this->visibility->forFile(
|
||||
$visibility
|
||||
);
|
||||
|
||||
$this->setPermissions($path, $visibility);
|
||||
}
|
||||
|
||||
public function visibility(string $path): FileAttributes
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
clearstatcache(false, $location);
|
||||
error_clear_last();
|
||||
$fileperms = @fileperms($location);
|
||||
|
||||
if ($fileperms === false) {
|
||||
throw UnableToRetrieveMetadata::visibility($path, error_get_last()['message'] ?? '');
|
||||
}
|
||||
|
||||
$permissions = $fileperms & 0777;
|
||||
$visibility = $this->visibility->inverseForFile($permissions);
|
||||
|
||||
return new FileAttributes($path, null, $visibility);
|
||||
}
|
||||
|
||||
private function resolveDirectoryVisibility(?string $visibility): int
|
||||
{
|
||||
return $visibility === null ? $this->visibility->defaultForDirectories() : $this->visibility->forDirectory(
|
||||
$visibility
|
||||
);
|
||||
}
|
||||
|
||||
public function mimeType(string $path): FileAttributes
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
error_clear_last();
|
||||
|
||||
if ( ! is_file($location)) {
|
||||
throw UnableToRetrieveMetadata::mimeType($location, 'No such file exists.');
|
||||
}
|
||||
|
||||
$mimeType = $this->mimeTypeDetector->detectMimeTypeFromFile($location);
|
||||
|
||||
if ($mimeType === null) {
|
||||
throw UnableToRetrieveMetadata::mimeType($path, error_get_last()['message'] ?? '');
|
||||
}
|
||||
|
||||
return new FileAttributes($path, null, null, null, $mimeType);
|
||||
}
|
||||
|
||||
public function lastModified(string $path): FileAttributes
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
error_clear_last();
|
||||
$lastModified = @filemtime($location);
|
||||
|
||||
if ($lastModified === false) {
|
||||
throw UnableToRetrieveMetadata::lastModified($path, error_get_last()['message'] ?? '');
|
||||
}
|
||||
|
||||
return new FileAttributes($path, null, null, $lastModified);
|
||||
}
|
||||
|
||||
public function fileSize(string $path): FileAttributes
|
||||
{
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
error_clear_last();
|
||||
|
||||
if (is_file($location) && ($fileSize = @filesize($location)) !== false) {
|
||||
return new FileAttributes($path, $fileSize);
|
||||
}
|
||||
|
||||
throw UnableToRetrieveMetadata::fileSize($path, error_get_last()['message'] ?? '');
|
||||
}
|
||||
|
||||
public function checksum(string $path, Config $config): string
|
||||
{
|
||||
$algo = $config->get('checksum_algo', 'md5');
|
||||
$location = $this->prefixer->prefixPath($path);
|
||||
error_clear_last();
|
||||
$checksum = @hash_file($algo, $location);
|
||||
|
||||
if ($checksum === false) {
|
||||
throw new UnableToProvideChecksum(error_get_last()['message'] ?? '', $path);
|
||||
}
|
||||
|
||||
return $checksum;
|
||||
}
|
||||
|
||||
private function listDirectory(string $location): Generator
|
||||
{
|
||||
$iterator = new DirectoryIterator($location);
|
||||
|
||||
foreach ($iterator as $item) {
|
||||
if ($item->isDot()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
yield $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function setPermissions(string $location, int $visibility): void
|
||||
{
|
||||
error_clear_last();
|
||||
if ( ! @chmod($location, $visibility)) {
|
||||
$extraMessage = error_get_last()['message'] ?? '';
|
||||
throw UnableToSetVisibility::atLocation($this->prefixer->stripPrefix($location), $extraMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
958
vendor/league/flysystem/src/MountManager.php
vendored
958
vendor/league/flysystem/src/MountManager.php
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use SplFileInfo;
|
||||
|
||||
class NotSupportedException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
/**
|
||||
* Create a new exception for a link.
|
||||
*
|
||||
* @param SplFileInfo $file
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forLink(SplFileInfo $file)
|
||||
{
|
||||
$message = 'Links are not supported, encountered link at ';
|
||||
|
||||
return new static($message . $file->getPathname());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new exception for a link.
|
||||
*
|
||||
* @param string $systemType
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forFtpSystemType($systemType)
|
||||
{
|
||||
$message = "The FTP system type '$systemType' is currently not supported.";
|
||||
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
10
vendor/league/flysystem/src/PathNormalizer.php
vendored
Normal file
10
vendor/league/flysystem/src/PathNormalizer.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface PathNormalizer
|
||||
{
|
||||
public function normalizePath(string $path): string;
|
||||
}
|
||||
50
vendor/league/flysystem/src/PathPrefixer.php
vendored
Normal file
50
vendor/league/flysystem/src/PathPrefixer.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use function rtrim;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
|
||||
final class PathPrefixer
|
||||
{
|
||||
private string $prefix = '';
|
||||
|
||||
public function __construct(string $prefix, private string $separator = '/')
|
||||
{
|
||||
$this->prefix = rtrim($prefix, '\\/');
|
||||
|
||||
if ($this->prefix !== '' || $prefix === $separator) {
|
||||
$this->prefix .= $separator;
|
||||
}
|
||||
}
|
||||
|
||||
public function prefixPath(string $path): string
|
||||
{
|
||||
return $this->prefix . ltrim($path, '\\/');
|
||||
}
|
||||
|
||||
public function stripPrefix(string $path): string
|
||||
{
|
||||
/* @var string */
|
||||
return substr($path, strlen($this->prefix));
|
||||
}
|
||||
|
||||
public function stripDirectoryPrefix(string $path): string
|
||||
{
|
||||
return rtrim($this->stripPrefix($path), '\\/');
|
||||
}
|
||||
|
||||
public function prefixDirectoryPath(string $path): string
|
||||
{
|
||||
$prefixedPath = $this->prefixPath(rtrim($path, '\\/'));
|
||||
|
||||
if ($prefixedPath === '' || substr($prefixedPath, -1) === $this->separator) {
|
||||
return $prefixedPath;
|
||||
}
|
||||
|
||||
return $prefixedPath . $this->separator;
|
||||
}
|
||||
}
|
||||
25
vendor/league/flysystem/src/PathTraversalDetected.php
vendored
Normal file
25
vendor/league/flysystem/src/PathTraversalDetected.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class PathTraversalDetected extends RuntimeException implements FilesystemException
|
||||
{
|
||||
private string $path;
|
||||
|
||||
public function path(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public static function forPath(string $path): PathTraversalDetected
|
||||
{
|
||||
$e = new PathTraversalDetected("Path traversal detected: {$path}");
|
||||
$e->path = $path;
|
||||
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
use League\Flysystem\FilesystemInterface;
|
||||
use League\Flysystem\PluginInterface;
|
||||
|
||||
abstract class AbstractPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @var FilesystemInterface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* Set the Filesystem object.
|
||||
*
|
||||
* @param FilesystemInterface $filesystem
|
||||
*/
|
||||
public function setFilesystem(FilesystemInterface $filesystem)
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
}
|
||||
34
vendor/league/flysystem/src/Plugin/EmptyDir.php
vendored
34
vendor/league/flysystem/src/Plugin/EmptyDir.php
vendored
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
class EmptyDir extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* Get the method name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'emptyDir';
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty a directory's contents.
|
||||
*
|
||||
* @param string $dirname
|
||||
*/
|
||||
public function handle($dirname)
|
||||
{
|
||||
$listing = $this->filesystem->listContents($dirname, false);
|
||||
|
||||
foreach ($listing as $item) {
|
||||
if ($item['type'] === 'dir') {
|
||||
$this->filesystem->deleteDir($item['path']);
|
||||
} else {
|
||||
$this->filesystem->delete($item['path']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
use League\Flysystem\FileExistsException;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class ForcedCopy extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'forceCopy';
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies a file, overwriting any existing files.
|
||||
*
|
||||
* @param string $path Path to the existing file.
|
||||
* @param string $newpath The new path of the file.
|
||||
*
|
||||
* @throws FileExistsException
|
||||
* @throws FileNotFoundException Thrown if $path does not exist.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function handle($path, $newpath)
|
||||
{
|
||||
try {
|
||||
$deleted = $this->filesystem->delete($newpath);
|
||||
} catch (FileNotFoundException $e) {
|
||||
// The destination path does not exist. That's ok.
|
||||
$deleted = true;
|
||||
}
|
||||
|
||||
if ($deleted) {
|
||||
return $this->filesystem->copy($path, $newpath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
use League\Flysystem\FileExistsException;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class ForcedRename extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'forceRename';
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames a file, overwriting the destination if it exists.
|
||||
*
|
||||
* @param string $path Path to the existing file.
|
||||
* @param string $newpath The new path of the file.
|
||||
*
|
||||
* @throws FileNotFoundException Thrown if $path does not exist.
|
||||
* @throws FileExistsException
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function handle($path, $newpath)
|
||||
{
|
||||
try {
|
||||
$deleted = $this->filesystem->delete($newpath);
|
||||
} catch (FileNotFoundException $e) {
|
||||
// The destination path does not exist. That's ok.
|
||||
$deleted = true;
|
||||
}
|
||||
|
||||
if ($deleted) {
|
||||
return $this->filesystem->rename($path, $newpath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class GetWithMetadata extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* Get the method name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'getWithMetadata';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get metadata for an object with required metadata.
|
||||
*
|
||||
* @param string $path path to file
|
||||
* @param string[] $metadata metadata keys
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return array|false metadata
|
||||
*/
|
||||
public function handle($path, array $metadata)
|
||||
{
|
||||
$object = $this->filesystem->getMetadata($path);
|
||||
|
||||
if ( ! $object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$keys = array_diff($metadata, array_keys($object));
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if ( ! method_exists($this->filesystem, $method = 'get' . ucfirst($key))) {
|
||||
throw new InvalidArgumentException('Could not fetch metadata: ' . $key);
|
||||
}
|
||||
|
||||
$object[$key] = $this->filesystem->{$method}($path);
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
35
vendor/league/flysystem/src/Plugin/ListFiles.php
vendored
35
vendor/league/flysystem/src/Plugin/ListFiles.php
vendored
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
class ListFiles extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* Get the method name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'listFiles';
|
||||
}
|
||||
|
||||
/**
|
||||
* List all files in the directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function handle($directory = '', $recursive = false)
|
||||
{
|
||||
$contents = $this->filesystem->listContents($directory, $recursive);
|
||||
|
||||
$filter = function ($object) {
|
||||
return $object['type'] === 'file';
|
||||
};
|
||||
|
||||
return array_values(array_filter($contents, $filter));
|
||||
}
|
||||
}
|
||||
36
vendor/league/flysystem/src/Plugin/ListPaths.php
vendored
36
vendor/league/flysystem/src/Plugin/ListPaths.php
vendored
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
class ListPaths extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* Get the method name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'listPaths';
|
||||
}
|
||||
|
||||
/**
|
||||
* List all paths.
|
||||
*
|
||||
* @param string $directory
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return string[] paths
|
||||
*/
|
||||
public function handle($directory = '', $recursive = false)
|
||||
{
|
||||
$result = [];
|
||||
$contents = $this->filesystem->listContents($directory, $recursive);
|
||||
|
||||
foreach ($contents as $object) {
|
||||
$result[] = $object['path'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
60
vendor/league/flysystem/src/Plugin/ListWith.php
vendored
60
vendor/league/flysystem/src/Plugin/ListWith.php
vendored
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
class ListWith extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* Get the method name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'listWith';
|
||||
}
|
||||
|
||||
/**
|
||||
* List contents with metadata.
|
||||
*
|
||||
* @param string[] $keys
|
||||
* @param string $directory
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return array listing with metadata
|
||||
*/
|
||||
public function handle(array $keys = [], $directory = '', $recursive = false)
|
||||
{
|
||||
$contents = $this->filesystem->listContents($directory, $recursive);
|
||||
|
||||
foreach ($contents as $index => $object) {
|
||||
if ($object['type'] === 'file') {
|
||||
$missingKeys = array_diff($keys, array_keys($object));
|
||||
$contents[$index] = array_reduce($missingKeys, [$this, 'getMetadataByName'], $object);
|
||||
}
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a meta-data value by key name.
|
||||
*
|
||||
* @param array $object
|
||||
* @param string $key
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getMetadataByName(array $object, $key)
|
||||
{
|
||||
$method = 'get' . ucfirst($key);
|
||||
|
||||
if ( ! method_exists($this->filesystem, $method)) {
|
||||
throw new \InvalidArgumentException('Could not get meta-data for key: ' . $key);
|
||||
}
|
||||
|
||||
$object[$key] = $this->filesystem->{$method}($object['path']);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
use BadMethodCallException;
|
||||
use League\Flysystem\FilesystemInterface;
|
||||
use League\Flysystem\PluginInterface;
|
||||
use LogicException;
|
||||
|
||||
trait PluggableTrait
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $plugins = [];
|
||||
|
||||
/**
|
||||
* Register a plugin.
|
||||
*
|
||||
* @param PluginInterface $plugin
|
||||
*
|
||||
* @throws LogicException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addPlugin(PluginInterface $plugin)
|
||||
{
|
||||
if ( ! method_exists($plugin, 'handle')) {
|
||||
throw new LogicException(get_class($plugin) . ' does not have a handle method.');
|
||||
}
|
||||
|
||||
$this->plugins[$plugin->getMethod()] = $plugin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a specific plugin.
|
||||
*
|
||||
* @param string $method
|
||||
*
|
||||
* @throws PluginNotFoundException
|
||||
*
|
||||
* @return PluginInterface
|
||||
*/
|
||||
protected function findPlugin($method)
|
||||
{
|
||||
if ( ! isset($this->plugins[$method])) {
|
||||
throw new PluginNotFoundException('Plugin not found for method: ' . $method);
|
||||
}
|
||||
|
||||
return $this->plugins[$method];
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke a plugin by method name.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
* @param FilesystemInterface $filesystem
|
||||
*
|
||||
* @throws PluginNotFoundException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function invokePlugin($method, array $arguments, FilesystemInterface $filesystem)
|
||||
{
|
||||
$plugin = $this->findPlugin($method);
|
||||
$plugin->setFilesystem($filesystem);
|
||||
$callback = [$plugin, 'handle'];
|
||||
|
||||
return call_user_func_array($callback, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugins pass-through.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
*
|
||||
* @throws BadMethodCallException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, array $arguments)
|
||||
{
|
||||
try {
|
||||
return $this->invokePlugin($method, $arguments, $this);
|
||||
} catch (PluginNotFoundException $e) {
|
||||
throw new BadMethodCallException(
|
||||
'Call to undefined method '
|
||||
. get_class($this)
|
||||
. '::' . $method
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
use LogicException;
|
||||
|
||||
class PluginNotFoundException extends LogicException
|
||||
{
|
||||
// This exception doesn't require additional information.
|
||||
}
|
||||
20
vendor/league/flysystem/src/PluginInterface.php
vendored
20
vendor/league/flysystem/src/PluginInterface.php
vendored
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface PluginInterface
|
||||
{
|
||||
/**
|
||||
* Get the method name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod();
|
||||
|
||||
/**
|
||||
* Set the Filesystem object.
|
||||
*
|
||||
* @param FilesystemInterface $filesystem
|
||||
*/
|
||||
public function setFilesystem(FilesystemInterface $filesystem);
|
||||
}
|
||||
19
vendor/league/flysystem/src/PortableVisibilityGuard.php
vendored
Normal file
19
vendor/league/flysystem/src/PortableVisibilityGuard.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
final class PortableVisibilityGuard
|
||||
{
|
||||
public static function guardAgainstInvalidInput(string $visibility): void
|
||||
{
|
||||
if ($visibility !== Visibility::PUBLIC && $visibility !== Visibility::PRIVATE) {
|
||||
$className = Visibility::class;
|
||||
throw InvalidVisibilityProvided::withVisibility(
|
||||
$visibility,
|
||||
"either {$className}::PUBLIC or {$className}::PRIVATE"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
62
vendor/league/flysystem/src/ProxyArrayAccessToProperties.php
vendored
Normal file
62
vendor/league/flysystem/src/ProxyArrayAccessToProperties.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
trait ProxyArrayAccessToProperties
|
||||
{
|
||||
private function formatPropertyName(string $offset): string
|
||||
{
|
||||
return str_replace('_', '', lcfirst(ucwords($offset, '_')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
$property = $this->formatPropertyName((string) $offset);
|
||||
|
||||
return isset($this->{$property});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
$property = $this->formatPropertyName((string) $offset);
|
||||
|
||||
return $this->{$property};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @param mixed $value
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
throw new RuntimeException('Properties can not be manipulated');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
throw new RuntimeException('Properties can not be manipulated');
|
||||
}
|
||||
}
|
||||
88
vendor/league/flysystem/src/ReadInterface.php
vendored
88
vendor/league/flysystem/src/ReadInterface.php
vendored
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface ReadInterface
|
||||
{
|
||||
/**
|
||||
* Check whether a file exists.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|bool|null
|
||||
*/
|
||||
public function has($path);
|
||||
|
||||
/**
|
||||
* Read a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function read($path);
|
||||
|
||||
/**
|
||||
* Read a file as a stream.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function readStream($path);
|
||||
|
||||
/**
|
||||
* List contents of a directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listContents($directory = '', $recursive = false);
|
||||
|
||||
/**
|
||||
* Get all the meta data of a file or directory.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function getMetadata($path);
|
||||
|
||||
/**
|
||||
* Get the size of a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function getSize($path);
|
||||
|
||||
/**
|
||||
* Get the mimetype of a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function getMimetype($path);
|
||||
|
||||
/**
|
||||
* Get the last modified time of a file as a timestamp.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function getTimestamp($path);
|
||||
|
||||
/**
|
||||
* Get the visibility of a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function getVisibility($path);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use LogicException;
|
||||
|
||||
class RootViolationException extends LogicException implements FilesystemException
|
||||
{
|
||||
//
|
||||
}
|
||||
39
vendor/league/flysystem/src/SafeStorage.php
vendored
39
vendor/league/flysystem/src/SafeStorage.php
vendored
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
final class SafeStorage
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $hash;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $safeStorage = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->hash = spl_object_hash($this);
|
||||
static::$safeStorage[$this->hash] = [];
|
||||
}
|
||||
|
||||
public function storeSafely($key, $value)
|
||||
{
|
||||
static::$safeStorage[$this->hash][$key] = $value;
|
||||
}
|
||||
|
||||
public function retrieveSafely($key)
|
||||
{
|
||||
if (array_key_exists($key, static::$safeStorage[$this->hash])) {
|
||||
return static::$safeStorage[$this->hash][$key];
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
unset(static::$safeStorage[$this->hash]);
|
||||
}
|
||||
}
|
||||
40
vendor/league/flysystem/src/StorageAttributes.php
vendored
Normal file
40
vendor/league/flysystem/src/StorageAttributes.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use ArrayAccess;
|
||||
use JsonSerializable;
|
||||
|
||||
interface StorageAttributes extends JsonSerializable, ArrayAccess
|
||||
{
|
||||
public const ATTRIBUTE_PATH = 'path';
|
||||
public const ATTRIBUTE_TYPE = 'type';
|
||||
public const ATTRIBUTE_FILE_SIZE = 'file_size';
|
||||
public const ATTRIBUTE_VISIBILITY = 'visibility';
|
||||
public const ATTRIBUTE_LAST_MODIFIED = 'last_modified';
|
||||
public const ATTRIBUTE_MIME_TYPE = 'mime_type';
|
||||
public const ATTRIBUTE_EXTRA_METADATA = 'extra_metadata';
|
||||
|
||||
public const TYPE_FILE = 'file';
|
||||
public const TYPE_DIRECTORY = 'dir';
|
||||
|
||||
public function path(): string;
|
||||
|
||||
public function type(): string;
|
||||
|
||||
public function visibility(): ?string;
|
||||
|
||||
public function lastModified(): ?int;
|
||||
|
||||
public static function fromArray(array $attributes): StorageAttributes;
|
||||
|
||||
public function isFile(): bool;
|
||||
|
||||
public function isDir(): bool;
|
||||
|
||||
public function withPath(string $path): StorageAttributes;
|
||||
|
||||
public function extraMetadata(): array;
|
||||
}
|
||||
25
vendor/league/flysystem/src/SymbolicLinkEncountered.php
vendored
Normal file
25
vendor/league/flysystem/src/SymbolicLinkEncountered.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
final class SymbolicLinkEncountered extends RuntimeException implements FilesystemException
|
||||
{
|
||||
private string $location;
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public static function atLocation(string $pathName): SymbolicLinkEncountered
|
||||
{
|
||||
$e = new static("Unsupported symbolic link encountered at location $pathName");
|
||||
$e->location = $pathName;
|
||||
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
13
vendor/league/flysystem/src/UnableToCheckDirectoryExistence.php
vendored
Normal file
13
vendor/league/flysystem/src/UnableToCheckDirectoryExistence.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
class UnableToCheckDirectoryExistence extends UnableToCheckExistence
|
||||
{
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_DIRECTORY_EXISTS;
|
||||
}
|
||||
}
|
||||
26
vendor/league/flysystem/src/UnableToCheckExistence.php
vendored
Normal file
26
vendor/league/flysystem/src/UnableToCheckExistence.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
class UnableToCheckExistence extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
final public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public static function forLocation(string $path, Throwable $exception = null): static
|
||||
{
|
||||
return new static("Unable to check existence for: {$path}", 0, $exception);
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_EXISTENCE_CHECK;
|
||||
}
|
||||
}
|
||||
13
vendor/league/flysystem/src/UnableToCheckFileExistence.php
vendored
Normal file
13
vendor/league/flysystem/src/UnableToCheckFileExistence.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
class UnableToCheckFileExistence extends UnableToCheckExistence
|
||||
{
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_FILE_EXISTS;
|
||||
}
|
||||
}
|
||||
48
vendor/league/flysystem/src/UnableToCopyFile.php
vendored
Normal file
48
vendor/league/flysystem/src/UnableToCopyFile.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToCopyFile extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $destination;
|
||||
|
||||
public function source(): string
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function destination(): string
|
||||
{
|
||||
return $this->destination;
|
||||
}
|
||||
|
||||
public static function fromLocationTo(
|
||||
string $sourcePath,
|
||||
string $destinationPath,
|
||||
Throwable $previous = null
|
||||
): UnableToCopyFile {
|
||||
$e = new static("Unable to copy file from $sourcePath to $destinationPath", 0 , $previous);
|
||||
$e->source = $sourcePath;
|
||||
$e->destination = $destinationPath;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_COPY;
|
||||
}
|
||||
}
|
||||
50
vendor/league/flysystem/src/UnableToCreateDirectory.php
vendored
Normal file
50
vendor/league/flysystem/src/UnableToCreateDirectory.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToCreateDirectory extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
private string $location;
|
||||
private string $reason = '';
|
||||
|
||||
public static function atLocation(string $dirname, string $errorMessage = '', ?Throwable $previous = null): UnableToCreateDirectory
|
||||
{
|
||||
$message = "Unable to create a directory at {$dirname}. {$errorMessage}";
|
||||
$e = new static(rtrim($message), 0, $previous);
|
||||
$e->location = $dirname;
|
||||
$e->reason = $errorMessage;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public static function dueToFailure(string $dirname, Throwable $previous): UnableToCreateDirectory
|
||||
{
|
||||
$reason = $previous instanceof UnableToCreateDirectory ? $previous->reason() : '';
|
||||
$message = "Unable to create a directory at $dirname. $reason";
|
||||
$e = new static(rtrim($message), 0, $previous);
|
||||
$e->location = $dirname;
|
||||
$e->reason = $reason ?: $message;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_CREATE_DIRECTORY;
|
||||
}
|
||||
|
||||
public function reason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
}
|
||||
48
vendor/league/flysystem/src/UnableToDeleteDirectory.php
vendored
Normal file
48
vendor/league/flysystem/src/UnableToDeleteDirectory.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToDeleteDirectory extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $reason;
|
||||
|
||||
public static function atLocation(
|
||||
string $location,
|
||||
string $reason = '',
|
||||
Throwable $previous = null
|
||||
): UnableToDeleteDirectory {
|
||||
$e = new static(rtrim("Unable to delete directory located at: {$location}. {$reason}"), 0, $previous);
|
||||
$e->location = $location;
|
||||
$e->reason = $reason;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_DELETE_DIRECTORY;
|
||||
}
|
||||
|
||||
public function reason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
}
|
||||
45
vendor/league/flysystem/src/UnableToDeleteFile.php
vendored
Normal file
45
vendor/league/flysystem/src/UnableToDeleteFile.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToDeleteFile extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $reason;
|
||||
|
||||
public static function atLocation(string $location, string $reason = '', Throwable $previous = null): UnableToDeleteFile
|
||||
{
|
||||
$e = new static(rtrim("Unable to delete file located at: {$location}. {$reason}"), 0, $previous);
|
||||
$e->location = $location;
|
||||
$e->reason = $reason;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_DELETE;
|
||||
}
|
||||
|
||||
public function reason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
}
|
||||
26
vendor/league/flysystem/src/UnableToGeneratePublicUrl.php
vendored
Normal file
26
vendor/league/flysystem/src/UnableToGeneratePublicUrl.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToGeneratePublicUrl extends RuntimeException implements FilesystemException
|
||||
{
|
||||
public function __construct(string $reason, string $path, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct("Unable to generate public url for $path: $reason", 0, $previous);
|
||||
}
|
||||
|
||||
public static function dueToError(string $path, Throwable $exception): static
|
||||
{
|
||||
return new static($exception->getMessage(), $path, $exception);
|
||||
}
|
||||
|
||||
public static function noGeneratorConfigured(string $path, string $extraReason = ''): static
|
||||
{
|
||||
return new static('No generator was configured ' . $extraReason, $path);
|
||||
}
|
||||
}
|
||||
26
vendor/league/flysystem/src/UnableToGenerateTemporaryUrl.php
vendored
Normal file
26
vendor/league/flysystem/src/UnableToGenerateTemporaryUrl.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToGenerateTemporaryUrl extends RuntimeException implements FilesystemException
|
||||
{
|
||||
public function __construct(string $reason, string $path, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct("Unable to generate temporary url for $path: $reason", 0, $previous);
|
||||
}
|
||||
|
||||
public static function dueToError(string $path, Throwable $exception): static
|
||||
{
|
||||
return new static($exception->getMessage(), $path, $exception);
|
||||
}
|
||||
|
||||
public static function noGeneratorConfigured(string $path, string $extraReason = ''): static
|
||||
{
|
||||
return new static('No generator was configured ' . $extraReason, $path);
|
||||
}
|
||||
}
|
||||
24
vendor/league/flysystem/src/UnableToListContents.php
vendored
Normal file
24
vendor/league/flysystem/src/UnableToListContents.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToListContents extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
public static function atLocation(string $location, bool $deep, Throwable $previous): UnableToListContents
|
||||
{
|
||||
$message = "Unable to list contents for '$location', " . ($deep ? 'deep' : 'shallow') . " listing\n\n"
|
||||
. 'Reason: ' . $previous->getMessage();
|
||||
|
||||
return new UnableToListContents($message, 0, $previous);
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return self::OPERATION_LIST_CONTENTS;
|
||||
}
|
||||
}
|
||||
32
vendor/league/flysystem/src/UnableToMountFilesystem.php
vendored
Normal file
32
vendor/league/flysystem/src/UnableToMountFilesystem.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use LogicException;
|
||||
|
||||
class UnableToMountFilesystem extends LogicException implements FilesystemException
|
||||
{
|
||||
/**
|
||||
* @param mixed $key
|
||||
*/
|
||||
public static function becauseTheKeyIsNotValid($key): UnableToMountFilesystem
|
||||
{
|
||||
return new UnableToMountFilesystem(
|
||||
'Unable to mount filesystem, key was invalid. String expected, received: ' . gettype($key)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $filesystem
|
||||
*/
|
||||
public static function becauseTheFilesystemWasNotValid($filesystem): UnableToMountFilesystem
|
||||
{
|
||||
$received = is_object($filesystem) ? get_class($filesystem) : gettype($filesystem);
|
||||
|
||||
return new UnableToMountFilesystem(
|
||||
'Unable to mount filesystem, filesystem was invalid. Instance of ' . FilesystemOperator::class . ' expected, received: ' . $received
|
||||
);
|
||||
}
|
||||
}
|
||||
49
vendor/league/flysystem/src/UnableToMoveFile.php
vendored
Normal file
49
vendor/league/flysystem/src/UnableToMoveFile.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToMoveFile extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $destination;
|
||||
|
||||
public function source(): string
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function destination(): string
|
||||
{
|
||||
return $this->destination;
|
||||
}
|
||||
|
||||
public static function fromLocationTo(
|
||||
string $sourcePath,
|
||||
string $destinationPath,
|
||||
Throwable $previous = null
|
||||
): UnableToMoveFile {
|
||||
$message = $previous?->getMessage() ?? "Unable to move file from $sourcePath to $destinationPath";
|
||||
$e = new static($message, 0, $previous);
|
||||
$e->source = $sourcePath;
|
||||
$e->destination = $destinationPath;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_MOVE;
|
||||
}
|
||||
}
|
||||
16
vendor/league/flysystem/src/UnableToProvideChecksum.php
vendored
Normal file
16
vendor/league/flysystem/src/UnableToProvideChecksum.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToProvideChecksum extends RuntimeException implements FilesystemException
|
||||
{
|
||||
public function __construct(string $reason, string $path, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct("Unable to get checksum for $path: $reason", 0, $previous);
|
||||
}
|
||||
}
|
||||
45
vendor/league/flysystem/src/UnableToReadFile.php
vendored
Normal file
45
vendor/league/flysystem/src/UnableToReadFile.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToReadFile extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $reason = '';
|
||||
|
||||
public static function fromLocation(string $location, string $reason = '', Throwable $previous = null): UnableToReadFile
|
||||
{
|
||||
$e = new static(rtrim("Unable to read file from location: {$location}. {$reason}"), 0, $previous);
|
||||
$e->location = $location;
|
||||
$e->reason = $reason;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_READ;
|
||||
}
|
||||
|
||||
public function reason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
}
|
||||
20
vendor/league/flysystem/src/UnableToResolveFilesystemMount.php
vendored
Normal file
20
vendor/league/flysystem/src/UnableToResolveFilesystemMount.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class UnableToResolveFilesystemMount extends RuntimeException implements FilesystemException
|
||||
{
|
||||
public static function becauseTheSeparatorIsMissing(string $path): UnableToResolveFilesystemMount
|
||||
{
|
||||
return new UnableToResolveFilesystemMount("Unable to resolve the filesystem mount because the path ($path) is missing a separator (://).");
|
||||
}
|
||||
|
||||
public static function becauseTheMountWasNotRegistered(string $mountIdentifier): UnableToResolveFilesystemMount
|
||||
{
|
||||
return new UnableToResolveFilesystemMount("Unable to resolve the filesystem mount because the mount ($mountIdentifier) was not registered.");
|
||||
}
|
||||
}
|
||||
76
vendor/league/flysystem/src/UnableToRetrieveMetadata.php
vendored
Normal file
76
vendor/league/flysystem/src/UnableToRetrieveMetadata.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToRetrieveMetadata extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $metadataType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $reason;
|
||||
|
||||
public static function lastModified(string $location, string $reason = '', Throwable $previous = null): self
|
||||
{
|
||||
return static::create($location, FileAttributes::ATTRIBUTE_LAST_MODIFIED, $reason, $previous);
|
||||
}
|
||||
|
||||
public static function visibility(string $location, string $reason = '', Throwable $previous = null): self
|
||||
{
|
||||
return static::create($location, FileAttributes::ATTRIBUTE_VISIBILITY, $reason, $previous);
|
||||
}
|
||||
|
||||
public static function fileSize(string $location, string $reason = '', Throwable $previous = null): self
|
||||
{
|
||||
return static::create($location, FileAttributes::ATTRIBUTE_FILE_SIZE, $reason, $previous);
|
||||
}
|
||||
|
||||
public static function mimeType(string $location, string $reason = '', Throwable $previous = null): self
|
||||
{
|
||||
return static::create($location, FileAttributes::ATTRIBUTE_MIME_TYPE, $reason, $previous);
|
||||
}
|
||||
|
||||
public static function create(string $location, string $type, string $reason = '', Throwable $previous = null): self
|
||||
{
|
||||
$e = new static("Unable to retrieve the $type for file at location: $location. {$reason}", 0, $previous);
|
||||
$e->reason = $reason;
|
||||
$e->location = $location;
|
||||
$e->metadataType = $type;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function reason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function metadataType(): string
|
||||
{
|
||||
return $this->metadataType;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_RETRIEVE_METADATA;
|
||||
}
|
||||
}
|
||||
49
vendor/league/flysystem/src/UnableToSetVisibility.php
vendored
Normal file
49
vendor/league/flysystem/src/UnableToSetVisibility.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
use Throwable;
|
||||
|
||||
use function rtrim;
|
||||
|
||||
final class UnableToSetVisibility extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $reason;
|
||||
|
||||
public function reason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public static function atLocation(string $filename, string $extraMessage = '', Throwable $previous = null): self
|
||||
{
|
||||
$message = "Unable to set visibility for file {$filename}. $extraMessage";
|
||||
$e = new static(rtrim($message), 0, $previous);
|
||||
$e->reason = $extraMessage;
|
||||
$e->location = $filename;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_SET_VISIBILITY;
|
||||
}
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
}
|
||||
45
vendor/league/flysystem/src/UnableToWriteFile.php
vendored
Normal file
45
vendor/league/flysystem/src/UnableToWriteFile.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class UnableToWriteFile extends RuntimeException implements FilesystemOperationFailed
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $reason;
|
||||
|
||||
public static function atLocation(string $location, string $reason = '', Throwable $previous = null): UnableToWriteFile
|
||||
{
|
||||
$e = new static(rtrim("Unable to write file at location: {$location}. {$reason}"), 0, $previous);
|
||||
$e->location = $location;
|
||||
$e->reason = $reason;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function operation(): string
|
||||
{
|
||||
return FilesystemOperationFailed::OPERATION_WRITE;
|
||||
}
|
||||
|
||||
public function reason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
}
|
||||
79
vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php
vendored
Normal file
79
vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\UnixVisibility;
|
||||
|
||||
use League\Flysystem\PortableVisibilityGuard;
|
||||
use League\Flysystem\Visibility;
|
||||
|
||||
class PortableVisibilityConverter implements VisibilityConverter
|
||||
{
|
||||
public function __construct(
|
||||
private int $filePublic = 0644,
|
||||
private int $filePrivate = 0600,
|
||||
private int $directoryPublic = 0755,
|
||||
private int $directoryPrivate = 0700,
|
||||
private string $defaultForDirectories = Visibility::PRIVATE
|
||||
) {
|
||||
}
|
||||
|
||||
public function forFile(string $visibility): int
|
||||
{
|
||||
PortableVisibilityGuard::guardAgainstInvalidInput($visibility);
|
||||
|
||||
return $visibility === Visibility::PUBLIC
|
||||
? $this->filePublic
|
||||
: $this->filePrivate;
|
||||
}
|
||||
|
||||
public function forDirectory(string $visibility): int
|
||||
{
|
||||
PortableVisibilityGuard::guardAgainstInvalidInput($visibility);
|
||||
|
||||
return $visibility === Visibility::PUBLIC
|
||||
? $this->directoryPublic
|
||||
: $this->directoryPrivate;
|
||||
}
|
||||
|
||||
public function inverseForFile(int $visibility): string
|
||||
{
|
||||
if ($visibility === $this->filePublic) {
|
||||
return Visibility::PUBLIC;
|
||||
} elseif ($visibility === $this->filePrivate) {
|
||||
return Visibility::PRIVATE;
|
||||
}
|
||||
|
||||
return Visibility::PUBLIC; // default
|
||||
}
|
||||
|
||||
public function inverseForDirectory(int $visibility): string
|
||||
{
|
||||
if ($visibility === $this->directoryPublic) {
|
||||
return Visibility::PUBLIC;
|
||||
} elseif ($visibility === $this->directoryPrivate) {
|
||||
return Visibility::PRIVATE;
|
||||
}
|
||||
|
||||
return Visibility::PUBLIC; // default
|
||||
}
|
||||
|
||||
public function defaultForDirectories(): int
|
||||
{
|
||||
return $this->defaultForDirectories === Visibility::PUBLIC ? $this->directoryPublic : $this->directoryPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed> $permissionMap
|
||||
*/
|
||||
public static function fromArray(array $permissionMap, string $defaultForDirectories = Visibility::PRIVATE): PortableVisibilityConverter
|
||||
{
|
||||
return new PortableVisibilityConverter(
|
||||
$permissionMap['file']['public'] ?? 0644,
|
||||
$permissionMap['file']['private'] ?? 0600,
|
||||
$permissionMap['dir']['public'] ?? 0755,
|
||||
$permissionMap['dir']['private'] ?? 0700,
|
||||
$defaultForDirectories
|
||||
);
|
||||
}
|
||||
}
|
||||
14
vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php
vendored
Normal file
14
vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\UnixVisibility;
|
||||
|
||||
interface VisibilityConverter
|
||||
{
|
||||
public function forFile(string $visibility): int;
|
||||
public function forDirectory(string $visibility): int;
|
||||
public function inverseForFile(int $visibility): string;
|
||||
public function inverseForDirectory(int $visibility): string;
|
||||
public function defaultForDirectories(): int;
|
||||
}
|
||||
28
vendor/league/flysystem/src/UnreadableFileEncountered.php
vendored
Normal file
28
vendor/league/flysystem/src/UnreadableFileEncountered.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
final class UnreadableFileEncountered extends RuntimeException implements FilesystemException
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
|
||||
public function location(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public static function atLocation(string $location): UnreadableFileEncountered
|
||||
{
|
||||
$e = new static("Unreadable file encountered at location {$location}.");
|
||||
$e->location = $location;
|
||||
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use SplFileInfo;
|
||||
|
||||
class UnreadableFileException extends Exception
|
||||
{
|
||||
public static function forFileInfo(SplFileInfo $fileInfo)
|
||||
{
|
||||
return new static(
|
||||
sprintf(
|
||||
'Unreadable file encountered: %s',
|
||||
$fileInfo->getRealPath()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
30
vendor/league/flysystem/src/UrlGeneration/ChainedPublicUrlGenerator.php
vendored
Normal file
30
vendor/league/flysystem/src/UrlGeneration/ChainedPublicUrlGenerator.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\UrlGeneration;
|
||||
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\UnableToGeneratePublicUrl;
|
||||
|
||||
final class ChainedPublicUrlGenerator implements PublicUrlGenerator
|
||||
{
|
||||
/**
|
||||
* @param PublicUrlGenerator[] $generators
|
||||
*/
|
||||
public function __construct(private iterable $generators)
|
||||
{
|
||||
}
|
||||
|
||||
public function publicUrl(string $path, Config $config): string
|
||||
{
|
||||
foreach ($this->generators as $generator) {
|
||||
try {
|
||||
return $generator->publicUrl($path, $config);
|
||||
} catch (UnableToGeneratePublicUrl) {
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnableToGeneratePublicUrl('No supported public url generator found.', $path);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user