|
|
|
@ -142,7 +142,7 @@ class OC_FilesystemView { |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public function getLocalFile($path) { |
|
|
|
|
$parent=substr($path, 0, strrpos($path,'/')); |
|
|
|
|
$parent=substr($path, 0, strrpos($path, '/')); |
|
|
|
|
if(OC_Filesystem::isValidPath($parent) and $storage=$this->getStorage($path)) { |
|
|
|
|
return $storage->getLocalFile($this->getInternalPath($path)); |
|
|
|
|
} |
|
|
|
@ -152,7 +152,7 @@ class OC_FilesystemView { |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public function getLocalFolder($path) { |
|
|
|
|
$parent=substr($path, 0, strrpos($path,'/')); |
|
|
|
|
$parent=substr($path, 0, strrpos($path, '/')); |
|
|
|
|
if(OC_Filesystem::isValidPath($parent) and $storage=$this->getStorage($path)) { |
|
|
|
|
return $storage->getLocalFolder($this->getInternalPath($path)); |
|
|
|
|
} |
|
|
|
@ -215,13 +215,13 @@ class OC_FilesystemView { |
|
|
|
|
* @deprecated Replaced by isReadable() as part of CRUDS |
|
|
|
|
*/ |
|
|
|
|
public function is_readable($path) { |
|
|
|
|
return $this->basicOperation('isReadable',$path); |
|
|
|
|
return $this->basicOperation('isReadable', $path); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* @deprecated Replaced by isCreatable(), isUpdatable(), isDeletable() as part of CRUDS |
|
|
|
|
*/ |
|
|
|
|
public function is_writable($path) { |
|
|
|
|
return $this->basicOperation('isUpdatable',$path); |
|
|
|
|
return $this->basicOperation('isUpdatable', $path); |
|
|
|
|
} |
|
|
|
|
public function isCreatable($path) { |
|
|
|
|
return $this->basicOperation('isCreatable', $path); |
|
|
|
@ -325,8 +325,8 @@ class OC_FilesystemView { |
|
|
|
|
return $this->basicOperation( 'deleteAll', $directory, array('delete'), $empty ); |
|
|
|
|
} |
|
|
|
|
public function rename($path1, $path2) { |
|
|
|
|
$postFix1=(substr($path1,-1,1)==='/')?'/':''; |
|
|
|
|
$postFix2=(substr($path2,-1,1)==='/')?'/':''; |
|
|
|
|
$postFix1=(substr($path1, -1, 1)==='/')?'/':''; |
|
|
|
|
$postFix2=(substr($path2, -1, 1)==='/')?'/':''; |
|
|
|
|
$absolutePath1 = OC_Filesystem::normalizePath($this->getAbsolutePath($path1)); |
|
|
|
|
$absolutePath2 = OC_Filesystem::normalizePath($this->getAbsolutePath($path2)); |
|
|
|
|
if(OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2) and OC_Filesystem::isValidPath($path2)) { |
|
|
|
@ -377,8 +377,8 @@ class OC_FilesystemView { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public function copy($path1, $path2) { |
|
|
|
|
$postFix1=(substr($path1,-1,1)==='/')?'/':''; |
|
|
|
|
$postFix2=(substr($path2,-1,1)==='/')?'/':''; |
|
|
|
|
$postFix1=(substr($path1, -1, 1)==='/')?'/':''; |
|
|
|
|
$postFix2=(substr($path2, -1, 1)==='/')?'/':''; |
|
|
|
|
$absolutePath1 = OC_Filesystem::normalizePath($this->getAbsolutePath($path1)); |
|
|
|
|
$absolutePath2 = OC_Filesystem::normalizePath($this->getAbsolutePath($path2)); |
|
|
|
|
if(OC_FileProxy::runPreProxies('copy', $absolutePath1, $absolutePath2) and OC_Filesystem::isValidPath($path2)) { |
|
|
|
@ -489,7 +489,7 @@ class OC_FilesystemView { |
|
|
|
|
$hooks[]='write'; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
OC_Log::write('core','invalid mode ('.$mode.') for '.$path,OC_Log::ERROR); |
|
|
|
|
OC_Log::write('core', 'invalid mode ('.$mode.') for '.$path,OC_Log::ERROR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $this->basicOperation('fopen', $path, $hooks, $mode); |
|
|
|
@ -501,7 +501,7 @@ class OC_FilesystemView { |
|
|
|
|
$extension=''; |
|
|
|
|
$extOffset=strpos($path, '.'); |
|
|
|
|
if($extOffset !== false) { |
|
|
|
|
$extension=substr($path, strrpos($path,'.')); |
|
|
|
|
$extension=substr($path, strrpos($path, '.')); |
|
|
|
|
} |
|
|
|
|
$tmpFile = OC_Helper::tmpFile($extension); |
|
|
|
|
file_put_contents($tmpFile, $source); |
|
|
|
@ -530,7 +530,7 @@ class OC_FilesystemView { |
|
|
|
|
return $this->basicOperation('getMimeType', $path); |
|
|
|
|
} |
|
|
|
|
public function hash($type, $path, $raw = false) { |
|
|
|
|
$postFix=(substr($path,-1,1)==='/')?'/':''; |
|
|
|
|
$postFix=(substr($path, -1, 1)==='/')?'/':''; |
|
|
|
|
$absolutePath = OC_Filesystem::normalizePath($this->getAbsolutePath($path)); |
|
|
|
|
if (OC_FileProxy::runPreProxies('hash', $absolutePath) && OC_Filesystem::isValidPath($path)) { |
|
|
|
|
$path = $this->getRelativePath($absolutePath); |
|
|
|
@ -570,7 +570,7 @@ class OC_FilesystemView { |
|
|
|
|
* OC_Filestorage for delegation to a storage backend for execution |
|
|
|
|
*/ |
|
|
|
|
private function basicOperation($operation, $path, $hooks=array(), $extraParam=null) { |
|
|
|
|
$postFix=(substr($path,-1,1)==='/')?'/':''; |
|
|
|
|
$postFix=(substr($path, -1, 1)==='/')?'/':''; |
|
|
|
|
$absolutePath = OC_Filesystem::normalizePath($this->getAbsolutePath($path)); |
|
|
|
|
if(OC_FileProxy::runPreProxies($operation, $absolutePath, $extraParam) and OC_Filesystem::isValidPath($path)) { |
|
|
|
|
$path = $this->getRelativePath($absolutePath); |
|
|
|
@ -578,7 +578,7 @@ class OC_FilesystemView { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$internalPath = $this->getInternalPath($path.$postFix); |
|
|
|
|
$run=$this->runHooks($hooks,$path); |
|
|
|
|
$run=$this->runHooks($hooks, $path); |
|
|
|
|
if($run and $storage = $this->getStorage($path.$postFix)) { |
|
|
|
|
if(!is_null($extraParam)) { |
|
|
|
|
$result = $storage->$operation($internalPath, $extraParam); |
|
|
|
@ -588,7 +588,7 @@ class OC_FilesystemView { |
|
|
|
|
$result = OC_FileProxy::runPostProxies($operation, $this->getAbsolutePath($path), $result); |
|
|
|
|
if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()) { |
|
|
|
|
if($operation!='fopen') {//no post hooks for fopen, the file stream is still open |
|
|
|
|
$this->runHooks($hooks,$path, true); |
|
|
|
|
$this->runHooks($hooks, $path, true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $result; |
|
|
|
|