|
|
|
|
@ -162,10 +162,48 @@ class SMB extends Common implements INotifyStorage { |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
protected function formatInfo($info) { |
|
|
|
|
return array( |
|
|
|
|
$result = [ |
|
|
|
|
'size' => $info->getSize(), |
|
|
|
|
'mtime' => $info->getMTime() |
|
|
|
|
); |
|
|
|
|
'mtime' => $info->getMTime(), |
|
|
|
|
]; |
|
|
|
|
if ($info->isDirectory()) { |
|
|
|
|
$result['type'] = 'dir'; |
|
|
|
|
} else { |
|
|
|
|
$result['type'] = 'file'; |
|
|
|
|
} |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Rename the files. If the source or the target is the root, the rename won't happen. |
|
|
|
|
* |
|
|
|
|
* @param string $source the old name of the path |
|
|
|
|
* @param string $target the new name of the path |
|
|
|
|
* @return bool true if the rename is successful, false otherwise |
|
|
|
|
*/ |
|
|
|
|
public function rename($source, $target) { |
|
|
|
|
$this->log("enter: rename('$source', '$target')", Util::DEBUG); |
|
|
|
|
|
|
|
|
|
if ($this->isRootDir($source) || $this->isRootDir($target)) { |
|
|
|
|
$this->log("refusing to rename \"$source\" to \"$target\""); |
|
|
|
|
return $this->leave(__FUNCTION__, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
$result = $this->share->rename($this->root . $source, $this->root . $target); |
|
|
|
|
$this->removeFromCache($this->root . $source); |
|
|
|
|
$this->removeFromCache($this->root . $target); |
|
|
|
|
} catch (AlreadyExistsException $e) { |
|
|
|
|
$this->unlink($target); |
|
|
|
|
$result = $this->share->rename($this->root . $source, $this->root . $target); |
|
|
|
|
$this->removeFromCache($this->root . $source); |
|
|
|
|
$this->removeFromCache($this->root . $target); |
|
|
|
|
$this->swallow(__FUNCTION__, $e); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
$this->swallow(__FUNCTION__, $e); |
|
|
|
|
$result = false; |
|
|
|
|
} |
|
|
|
|
return $this->leave(__FUNCTION__, $result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -220,6 +258,13 @@ class SMB extends Common implements INotifyStorage { |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
public function unlink($path) { |
|
|
|
|
$this->log('enter: '.__FUNCTION__."($path)"); |
|
|
|
|
|
|
|
|
|
if ($this->isRootDir($path)) { |
|
|
|
|
$this->log("refusing to unlink \"$path\""); |
|
|
|
|
return $this->leave(__FUNCTION__, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if ($this->is_dir($path)) { |
|
|
|
|
return $this->rmdir($path); |
|
|
|
|
@ -343,6 +388,13 @@ class SMB extends Common implements INotifyStorage { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function rmdir($path) { |
|
|
|
|
$this->log('enter: '.__FUNCTION__."($path)"); |
|
|
|
|
|
|
|
|
|
if ($this->isRootDir($path)) { |
|
|
|
|
$this->log("refusing to delete \"$path\""); |
|
|
|
|
return $this->leave(__FUNCTION__, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
$this->statCache = array(); |
|
|
|
|
$content = $this->share->dir($this->buildPath($path)); |
|
|
|
|
@ -439,6 +491,8 @@ class SMB extends Common implements INotifyStorage { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function isUpdatable($path) { |
|
|
|
|
$this->log('enter: '.__FUNCTION__."($path)"); |
|
|
|
|
$result = false; |
|
|
|
|
try { |
|
|
|
|
$info = $this->getFileInfo($path); |
|
|
|
|
// following windows behaviour for read-only folders: they can be written into |
|
|
|
|
@ -449,9 +503,12 @@ class SMB extends Common implements INotifyStorage { |
|
|
|
|
} catch (ForbiddenException $e) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return $this->leave(__FUNCTION__, $result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function isDeletable($path) { |
|
|
|
|
$this->log('enter: '.__FUNCTION__."($path)"); |
|
|
|
|
$result = false; |
|
|
|
|
try { |
|
|
|
|
$info = $this->getFileInfo($path); |
|
|
|
|
return !$info->isHidden() && !$info->isReadOnly(); |
|
|
|
|
|