mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-08-29 09:50:40 +02:00
Merge branch 'master' into develop
# Conflicts: # src/PhpZip/ZipFile.php # tests/PhpZip/ZipFileTest.php
This commit is contained in:
@@ -69,7 +69,6 @@ class ZipFile implements ZipFileInterface
|
||||
* @var ZipInputStreamInterface Input seekable input stream.
|
||||
*/
|
||||
protected $inputStream;
|
||||
|
||||
/**
|
||||
* @var ZipModel
|
||||
*/
|
||||
@@ -93,7 +92,7 @@ class ZipFile implements ZipFileInterface
|
||||
public function openFile($filename)
|
||||
{
|
||||
if (!file_exists($filename)) {
|
||||
throw new ZipException("File $filename can't exists.");
|
||||
throw new InvalidArgumentException("File $filename does not exist.");
|
||||
}
|
||||
if (!($handle = @fopen($filename, 'rb'))) {
|
||||
throw new ZipException("File $filename can't open.");
|
||||
@@ -560,10 +559,10 @@ class ZipFile implements ZipFileInterface
|
||||
}
|
||||
$inputDir = (string)$inputDir;
|
||||
if (strlen($inputDir) === 0) {
|
||||
throw new InvalidArgumentException('Input dir empty');
|
||||
throw new InvalidArgumentException('The input directory is not specified');
|
||||
}
|
||||
if (!is_dir($inputDir)) {
|
||||
throw new ZipException('Directory ' . $inputDir . ' can\'t exists');
|
||||
throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
|
||||
}
|
||||
$inputDir = rtrim($inputDir, '/\\') . DIRECTORY_SEPARATOR;
|
||||
|
||||
@@ -587,12 +586,15 @@ class ZipFile implements ZipFileInterface
|
||||
*/
|
||||
public function addDirRecursive($inputDir, $localPath = "/", $compressionMethod = null)
|
||||
{
|
||||
if ($inputDir === null) {
|
||||
throw new InvalidArgumentException('Input dir is null');
|
||||
}
|
||||
$inputDir = (string)$inputDir;
|
||||
if (null === $inputDir || strlen($inputDir) === 0) {
|
||||
throw new InvalidArgumentException('Input dir empty');
|
||||
if (strlen($inputDir) === 0) {
|
||||
throw new InvalidArgumentException('The input directory is not specified');
|
||||
}
|
||||
if (!is_dir($inputDir)) {
|
||||
throw new InvalidArgumentException('Directory ' . $inputDir . ' can\'t exists');
|
||||
throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
|
||||
}
|
||||
$inputDir = rtrim($inputDir, '/\\') . DIRECTORY_SEPARATOR;
|
||||
|
||||
@@ -703,16 +705,19 @@ class ZipFile implements ZipFileInterface
|
||||
$recursive = true,
|
||||
$compressionMethod = null
|
||||
) {
|
||||
if ($inputDir === null) {
|
||||
throw new InvalidArgumentException('Input dir is null');
|
||||
}
|
||||
$inputDir = (string)$inputDir;
|
||||
if (strlen($inputDir) === 0) {
|
||||
throw new InvalidArgumentException('Input dir empty');
|
||||
throw new InvalidArgumentException('The input directory is not specified');
|
||||
}
|
||||
if (!is_dir($inputDir)) {
|
||||
throw new ZipException('Directory ' . $inputDir . ' can\'t exists');
|
||||
throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
|
||||
}
|
||||
$globPattern = (string)$globPattern;
|
||||
if (empty($globPattern)) {
|
||||
throw new InvalidArgumentException("glob pattern empty");
|
||||
throw new InvalidArgumentException('The glob pattern is not specified');
|
||||
}
|
||||
|
||||
$inputDir = rtrim($inputDir, '/\\') . DIRECTORY_SEPARATOR;
|
||||
@@ -801,14 +806,14 @@ class ZipFile implements ZipFileInterface
|
||||
) {
|
||||
$regexPattern = (string)$regexPattern;
|
||||
if (empty($regexPattern)) {
|
||||
throw new InvalidArgumentException("regex pattern empty");
|
||||
throw new InvalidArgumentException('The regex pattern is not specified');
|
||||
}
|
||||
$inputDir = (string)$inputDir;
|
||||
if (strlen($inputDir) === 0) {
|
||||
throw new InvalidArgumentException('Input dir empty');
|
||||
throw new InvalidArgumentException('The input directory is not specified');
|
||||
}
|
||||
if (!is_dir($inputDir)) {
|
||||
throw new InvalidArgumentException('Directory ' . $inputDir . ' can\'t exists');
|
||||
throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
|
||||
}
|
||||
$inputDir = rtrim($inputDir, '/\\') . DIRECTORY_SEPARATOR;
|
||||
|
||||
@@ -876,7 +881,6 @@ class ZipFile implements ZipFileInterface
|
||||
* @param string $oldName Old entry name.
|
||||
* @param string $newName New entry name.
|
||||
* @return ZipFileInterface
|
||||
*
|
||||
* @throws ZipException
|
||||
*/
|
||||
public function rename($oldName, $newName)
|
||||
@@ -918,7 +922,7 @@ class ZipFile implements ZipFileInterface
|
||||
public function deleteFromGlob($globPattern)
|
||||
{
|
||||
if ($globPattern === null || !is_string($globPattern) || empty($globPattern)) {
|
||||
throw new InvalidArgumentException("Glob pattern is empty");
|
||||
throw new InvalidArgumentException("The glob pattern is not specified");
|
||||
}
|
||||
$globPattern = '~' . FilesUtil::convertGlobToRegEx($globPattern) . '~si';
|
||||
$this->deleteFromRegex($globPattern);
|
||||
@@ -934,7 +938,7 @@ class ZipFile implements ZipFileInterface
|
||||
public function deleteFromRegex($regexPattern)
|
||||
{
|
||||
if ($regexPattern === null || !is_string($regexPattern) || empty($regexPattern)) {
|
||||
throw new InvalidArgumentException("Regex pattern is empty.");
|
||||
throw new InvalidArgumentException("The regex pattern is not specified");
|
||||
}
|
||||
$this->matcher()->match($regexPattern)->delete();
|
||||
return $this;
|
||||
|
Reference in New Issue
Block a user