log fopen errors

This commit is contained in:
Robin Appelman 2016-01-19 19:33:46 +01:00
commit b538cf38d0

View file

@ -198,9 +198,15 @@ class NativeShare extends AbstractShare {
* @throws \Icewind\SMB\Exception\InvalidResourceException * @throws \Icewind\SMB\Exception\InvalidResourceException
*/ */
public function get($source, $target) { public function get($source, $target) {
$targetHandle = fopen($target, 'wb'); $targetHandle = @fopen($target, 'wb');
if (!$targetHandle) { if (!$targetHandle) {
throw new InvalidResourceException('Failed opening local file "' . $target . '" for writing'); $error = error_get_last();
if (is_array($error)) {
$reason = $error['message'];
} else {
$reason = 'Unknown error';
}
throw new InvalidResourceException('Failed opening local file "' . $target . '" for writing: ' . $reason);
} }
$this->connect(); $this->connect();