aboutsummaryrefslogtreecommitdiffstats
path: root/lib/filesystemview.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/filesystemview.php')
-rw-r--r--lib/filesystemview.php32
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index 89e0385fe9c..95873bd87cf 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -23,11 +23,11 @@
class OC_FilesystemView {
private $fakeRoot='';
-
+
public function __construct($root){
$this->fakeRoot=$root;
}
-
+
public function getAbsolutePath($path){
if(!$path){
$path='/';
@@ -137,13 +137,16 @@ class OC_FilesystemView {
}
public function readfile($path){
$handle=$this->fopen($path,'r');
- $chunkSize = 1024*1024;// 1 MB chunks
- while (!feof($handle)) {
- echo fread($handle, $chunkSize);
- @ob_flush();
- flush();
+ if ($handle) {
+ $chunkSize = 1024*1024;// 1 MB chunks
+ while (!feof($handle)) {
+ echo fread($handle, $chunkSize);
+ @ob_flush();
+ flush();
+ }
+ return $this->filesize($path);
}
- return $this->filesize($path);
+ return false;
}
public function is_readable($path){
return $this->basicOperation('is_readable',$path);
@@ -189,7 +192,7 @@ class OC_FilesystemView {
return $this->basicOperation('unlink',$path,array('delete'));
}
public function rename($path1,$path2){
- if(OC_FileProxy::runPreProxies('rename',$path1,$path2) and $this->is_writable($path1) and OC_Filesystem::isValidPath($path2)){
+ if(OC_FileProxy::runPreProxies('rename',$path1,$path2) and OC_Filesystem::isValidPath($path2)){
$run=true;
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, array( OC_Filesystem::signal_param_oldpath => $path1 , OC_Filesystem::signal_param_newpath=>$path2, OC_Filesystem::signal_param_run => &$run));
if($run){
@@ -280,9 +283,14 @@ class OC_FilesystemView {
if(OC_Filesystem::isValidPath($path)){
$source=$this->fopen($path,'r');
if($source){
- $extention=substr($path,strrpos($path,'.'));
- $tmpFile=OC_Helper::tmpFile($extention);
- return file_put_contents($tmpFile,$source);
+ $extension='';
+ $extOffset=strpos($path,'.');
+ if($extOffset !== false) {
+ $extension=substr($path,strrpos($path,'.'));
+ }
+ $tmpFile=OC_Helper::tmpFile($extension);
+ file_put_contents($tmpFile,$source);
+ return $tmpFile;
}
}
}