mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
require php5.6+
This commit is contained in:
parent
f258947a6f
commit
0cbfd0872d
5 changed files with 47 additions and 37 deletions
|
|
@ -7,7 +7,19 @@
|
|||
|
||||
namespace Icewind\SMB;
|
||||
|
||||
use Icewind\SMB\Exception\AlreadyExistsException;
|
||||
use Icewind\SMB\Exception\ConnectionRefusedException;
|
||||
use Icewind\SMB\Exception\Exception;
|
||||
use Icewind\SMB\Exception\FileInUseException;
|
||||
use Icewind\SMB\Exception\ForbiddenException;
|
||||
use Icewind\SMB\Exception\HostDownException;
|
||||
use Icewind\SMB\Exception\InvalidArgumentException;
|
||||
use Icewind\SMB\Exception\InvalidTypeException;
|
||||
use Icewind\SMB\Exception\NoRouteToHostException;
|
||||
use Icewind\SMB\Exception\NotEmptyException;
|
||||
use Icewind\SMB\Exception\NotFoundException;
|
||||
use Icewind\SMB\Exception\OutOfSpaceException;
|
||||
use Icewind\SMB\Exception\TimedOutException;
|
||||
|
||||
/**
|
||||
* Low level wrapper for libsmbclient-php with error handling
|
||||
|
|
@ -22,23 +34,22 @@ class NativeState {
|
|||
|
||||
protected $connected = false;
|
||||
|
||||
// todo replace with static once <5.6 support is dropped
|
||||
// see error.h
|
||||
private static $exceptionMap = [
|
||||
1 => '\Icewind\SMB\Exception\ForbiddenException',
|
||||
2 => '\Icewind\SMB\Exception\NotFoundException',
|
||||
13 => '\Icewind\SMB\Exception\ForbiddenException',
|
||||
16 => '\Icewind\SMB\Exception\FileInUseException',
|
||||
17 => '\Icewind\SMB\Exception\AlreadyExistsException',
|
||||
20 => '\Icewind\SMB\Exception\InvalidTypeException',
|
||||
21 => '\Icewind\SMB\Exception\InvalidTypeException',
|
||||
22 => '\Icewind\SMB\Exception\InvalidArgumentException',
|
||||
28 => '\Icewind\SMB\Exception\OutOfSpaceException',
|
||||
39 => '\Icewind\SMB\Exception\NotEmptyException',
|
||||
110 => '\Icewind\SMB\Exception\TimedOutException',
|
||||
111 => '\Icewind\SMB\Exception\ConnectionRefusedException',
|
||||
112 => '\Icewind\SMB\Exception\HostDownException',
|
||||
113 => '\Icewind\SMB\Exception\NoRouteToHostException'
|
||||
const EXCEPTION_MAP = [
|
||||
1 => ForbiddenException::class,
|
||||
2 => NotFoundException::class,
|
||||
13 => ForbiddenException::class,
|
||||
16 => FileInUseException::class,
|
||||
17 => AlreadyExistsException::class,
|
||||
20 => InvalidTypeException::class,
|
||||
21 => InvalidTypeException::class,
|
||||
22 => InvalidArgumentException::class,
|
||||
28 => OutOfSpaceException::class,
|
||||
39 => NotEmptyException::class,
|
||||
110 => TimedOutException::class,
|
||||
111 => ConnectionRefusedException::class,
|
||||
112 => HostDownException::class,
|
||||
113 => NoRouteToHostException::class
|
||||
];
|
||||
|
||||
protected function handleError($path) {
|
||||
|
|
@ -46,7 +57,7 @@ class NativeState {
|
|||
if ($error === 0) {
|
||||
return;
|
||||
}
|
||||
throw Exception::fromMap(self::$exceptionMap, $error, $path);
|
||||
throw Exception::fromMap(self::EXCEPTION_MAP, $error, $path);
|
||||
}
|
||||
|
||||
protected function testResult($result, $uri) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace Icewind\SMB;
|
|||
|
||||
|
||||
use Icewind\SMB\Exception\Exception;
|
||||
use Icewind\SMB\Exception\RevisionMismatchException;
|
||||
|
||||
class NotifyHandler implements INotifyHandler {
|
||||
/**
|
||||
|
|
@ -24,10 +25,9 @@ class NotifyHandler implements INotifyHandler {
|
|||
|
||||
private $listening = true;
|
||||
|
||||
// todo replace with static once <5.6 support is dropped
|
||||
// see error.h
|
||||
private static $exceptionMap = [
|
||||
ErrorCodes::RevisionMismatch => '\Icewind\SMB\Exception\RevisionMismatchException',
|
||||
const EXCEPTION_MAP = [
|
||||
ErrorCodes::RevisionMismatch => RevisionMismatchException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -93,7 +93,7 @@ class NotifyHandler implements INotifyHandler {
|
|||
private function checkForError($line) {
|
||||
if (substr($line, 0, 16) === 'notify returned ') {
|
||||
$error = substr($line, 16);
|
||||
throw Exception::fromMap(self::$exceptionMap, $error, 'Notify is not supported with the used smb version');
|
||||
throw Exception::fromMap(array_merge(self::EXCEPTION_MAP, Parser::EXCEPTION_MAP), $error, 'Notify is not supported with the used smb version');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use Icewind\SMB\Exception\AuthenticationException;
|
|||
use Icewind\SMB\Exception\Exception;
|
||||
use Icewind\SMB\Exception\FileInUseException;
|
||||
use Icewind\SMB\Exception\InvalidHostException;
|
||||
use Icewind\SMB\Exception\InvalidParameterException;
|
||||
use Icewind\SMB\Exception\InvalidResourceException;
|
||||
use Icewind\SMB\Exception\InvalidTypeException;
|
||||
use Icewind\SMB\Exception\NoLoginServerException;
|
||||
|
|
@ -29,18 +30,18 @@ class Parser {
|
|||
|
||||
// todo replace with static once <5.6 support is dropped
|
||||
// see error.h
|
||||
private static $exceptionMap = [
|
||||
ErrorCodes::LogonFailure => '\Icewind\SMB\Exception\AuthenticationException',
|
||||
ErrorCodes::PathNotFound => '\Icewind\SMB\Exception\NotFoundException',
|
||||
ErrorCodes::ObjectNotFound => '\Icewind\SMB\Exception\NotFoundException',
|
||||
ErrorCodes::NoSuchFile => '\Icewind\SMB\Exception\NotFoundException',
|
||||
ErrorCodes::NameCollision => '\Icewind\SMB\Exception\AlreadyExistsException',
|
||||
ErrorCodes::AccessDenied => '\Icewind\SMB\Exception\AccessDeniedException',
|
||||
ErrorCodes::DirectoryNotEmpty => '\Icewind\SMB\Exception\NotEmptyException',
|
||||
ErrorCodes::FileIsADirectory => '\Icewind\SMB\Exception\InvalidTypeException',
|
||||
ErrorCodes::NotADirectory => '\Icewind\SMB\Exception\InvalidTypeException',
|
||||
ErrorCodes::SharingViolation => '\Icewind\SMB\Exception\FileInUseException',
|
||||
ErrorCodes::InvalidParameter => '\Icewind\SMB\Exception\InvalidParameterException'
|
||||
const EXCEPTION_MAP = [
|
||||
ErrorCodes::LogonFailure => AuthenticationException::class,
|
||||
ErrorCodes::PathNotFound => NotFoundException::class,
|
||||
ErrorCodes::ObjectNotFound => NotFoundException::class,
|
||||
ErrorCodes::NoSuchFile => NotFoundException::class,
|
||||
ErrorCodes::NameCollision => AlreadyExistsException::class,
|
||||
ErrorCodes::AccessDenied => AccessDeniedException::class,
|
||||
ErrorCodes::DirectoryNotEmpty => NotEmptyException::class,
|
||||
ErrorCodes::FileIsADirectory => InvalidTypeException::class,
|
||||
ErrorCodes::NotADirectory => InvalidTypeException::class,
|
||||
ErrorCodes::SharingViolation => FileInUseException::class,
|
||||
ErrorCodes::InvalidParameter => InvalidParameterException::class
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +72,7 @@ class Parser {
|
|||
throw new InvalidResourceException('Failed opening local file "' . $localPath . '" for writing');
|
||||
}
|
||||
|
||||
throw Exception::fromMap(self::$exceptionMap, $error, $path);
|
||||
throw Exception::fromMap(self::EXCEPTION_MAP, $error, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue