Run pre and post proxies for file_put_contents() streams
Conflicts: lib/filesystemview.php
This commit is contained in:
parent
41a74e3dd2
commit
ea18d70c60
|
@ -198,29 +198,56 @@ class OC_FilesystemView {
|
||||||
public function file_get_contents($path){
|
public function file_get_contents($path){
|
||||||
return $this->basicOperation('file_get_contents',$path,array('read'));
|
return $this->basicOperation('file_get_contents',$path,array('read'));
|
||||||
}
|
}
|
||||||
public function file_put_contents($path,$data){
|
public function file_put_contents($path, $data) {
|
||||||
if(is_resource($data)){//not having to deal with streams in file_put_contents makes life easier
|
if(is_resource($data)) {//not having to deal with streams in file_put_contents makes life easier
|
||||||
$exists=$this->file_exists($path);
|
$absolutePath = $this->getAbsolutePath($path);
|
||||||
$run=true;
|
if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath) && OC_Filesystem::isValidPath($path)) {
|
||||||
if(!$exists){
|
$path = $this->getRelativePath($absolutePath);
|
||||||
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
|
$exists = $this->file_exists($path);
|
||||||
}
|
$run = true;
|
||||||
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
|
if(!$exists) {
|
||||||
if(!$run){
|
OC_Hook::emit(
|
||||||
return false;
|
OC_Filesystem::CLASSNAME,
|
||||||
}
|
OC_Filesystem::signal_create,
|
||||||
$target=$this->fopen($path,'w');
|
array(
|
||||||
if($target){
|
OC_Filesystem::signal_param_path => $path,
|
||||||
$count=OC_Helper::streamCopy($data,$target);
|
OC_Filesystem::signal_param_run => &$run
|
||||||
fclose($target);
|
)
|
||||||
fclose($data);
|
);
|
||||||
if(!$exists){
|
}
|
||||||
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array( OC_Filesystem::signal_param_path => $path));
|
OC_Hook::emit(
|
||||||
|
OC_Filesystem::CLASSNAME,
|
||||||
|
OC_Filesystem::signal_write,
|
||||||
|
array(
|
||||||
|
OC_Filesystem::signal_param_path => $path,
|
||||||
|
OC_Filesystem::signal_param_run => &$run
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if(!$run) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$target=$this->fopen($path, 'w');
|
||||||
|
if($target) {
|
||||||
|
$count=OC_Helper::streamCopy($data, $target);
|
||||||
|
fclose($target);
|
||||||
|
fclose($data);
|
||||||
|
if(!$exists) {
|
||||||
|
OC_Hook::emit(
|
||||||
|
OC_Filesystem::CLASSNAME,
|
||||||
|
OC_Filesystem::signal_post_create,
|
||||||
|
array( OC_Filesystem::signal_param_path => $path)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
OC_Hook::emit(
|
||||||
|
OC_Filesystem::CLASSNAME,
|
||||||
|
OC_Filesystem::signal_post_write,
|
||||||
|
array( OC_Filesystem::signal_param_path => $path)
|
||||||
|
);
|
||||||
|
OC_FileProxy::runPostProxies('hash', $absolutePath, $count);
|
||||||
|
return $count > 0;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array( OC_Filesystem::signal_param_path => $path));
|
|
||||||
return $count>0;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return $this->basicOperation('file_put_contents',$path,array('create','write'),$data);
|
return $this->basicOperation('file_put_contents',$path,array('create','write'),$data);
|
||||||
|
|
Loading…
Reference in New Issue