diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
commit | caff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch) | |
tree | 186d494c2aea5dea7255d3584ef5d595fc6e6194 /lib/private/Archive | |
parent | edf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff) | |
download | nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip |
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds
unified formatting for control structures like if and loops as well as
classes, their methods and anonymous functions. This basically forces
the constructs to start on the same line. This is not exactly what PSR2
wants, but I think we can have a few exceptions with "our" style. The
starting of braces on the same line is pracrically standard for our
code.
This also removes and empty lines from method/function bodies at the
beginning and end.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Archive')
-rw-r--r-- | lib/private/Archive/Archive.php | 8 | ||||
-rw-r--r-- | lib/private/Archive/ZIP.php | 36 |
2 files changed, 22 insertions, 22 deletions
diff --git a/lib/private/Archive/Archive.php b/lib/private/Archive/Archive.php index 94956561c3e..5150e6ddee3 100644 --- a/lib/private/Archive/Archive.php +++ b/lib/private/Archive/Archive.php @@ -123,15 +123,15 @@ abstract class Archive { */ public function addRecursive($path, $source) { $dh = opendir($source); - if(is_resource($dh)) { + if (is_resource($dh)) { $this->addFolder($path); while (($file = readdir($dh)) !== false) { - if($file === '.' || $file === '..') { + if ($file === '.' || $file === '..') { continue; } - if(is_dir($source.'/'.$file)) { + if (is_dir($source.'/'.$file)) { $this->addRecursive($path.'/'.$file, $source.'/'.$file); - }else{ + } else { $this->addFile($path.'/'.$file, $source.'/'.$file); } } diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index cca6fd68c4e..31aea420a3d 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -35,7 +35,7 @@ namespace OC\Archive; use Icewind\Streams\CallbackWrapper; use OCP\ILogger; -class ZIP extends Archive{ +class ZIP extends Archive { /** * @var \ZipArchive zip */ @@ -48,8 +48,8 @@ class ZIP extends Archive{ public function __construct($source) { $this->path=$source; $this->zip=new \ZipArchive(); - if($this->zip->open($source, \ZipArchive::CREATE)) { - }else{ + if ($this->zip->open($source, \ZipArchive::CREATE)) { + } else { \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); } } @@ -68,12 +68,12 @@ class ZIP extends Archive{ * @return bool */ public function addFile($path, $source='') { - if($source and $source[0]=='/' and file_exists($source)) { + if ($source and $source[0]=='/' and file_exists($source)) { $result=$this->zip->addFile($source, $path); - }else{ + } else { $result=$this->zip->addFromString($path, $source); } - if($result) { + if ($result) { $this->zip->close();//close and reopen to save the zip $this->zip->open($this->path); } @@ -116,9 +116,9 @@ class ZIP extends Archive{ $files=$this->getFiles(); $folderContent=[]; $pathLength=strlen($path); - foreach($files as $file) { - if(substr($file, 0, $pathLength)==$path and $file!=$path) { - if(strrpos(substr($file, 0, -1), '/')<=$pathLength) { + foreach ($files as $file) { + if (substr($file, 0, $pathLength)==$path and $file!=$path) { + if (strrpos(substr($file, 0, -1), '/')<=$pathLength) { $folderContent[]=substr($file, $pathLength); } } @@ -132,7 +132,7 @@ class ZIP extends Archive{ public function getFiles() { $fileCount=$this->zip->numFiles; $files=[]; - for($i=0;$i<$fileCount;$i++) { + for ($i=0;$i<$fileCount;$i++) { $files[]=$this->zip->getNameIndex($i); } return $files; @@ -177,9 +177,9 @@ class ZIP extends Archive{ * @return bool */ public function remove($path) { - if($this->fileExists($path.'/')) { + if ($this->fileExists($path.'/')) { return $this->zip->deleteName($path.'/'); - }else{ + } else { return $this->zip->deleteName($path); } } @@ -190,19 +190,19 @@ class ZIP extends Archive{ * @return resource */ public function getStream($path, $mode) { - if($mode=='r' or $mode=='rb') { + if ($mode=='r' or $mode=='rb') { return $this->zip->getStream($path); } else { //since we can't directly get a writable stream, //make a temp copy of the file and put it back //in the archive when the stream is closed - if(strrpos($path, '.')!==false) { + if (strrpos($path, '.')!==false) { $ext=substr($path, strrpos($path, '.')); - }else{ + } else { $ext=''; } $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); - if($this->fileExists($path)) { + if ($this->fileExists($path)) { $this->extractFile($path, $tmpFile); } $handle = fopen($tmpFile, $mode); @@ -225,9 +225,9 @@ class ZIP extends Archive{ * @return string */ private function stripPath($path) { - if(!$path || $path[0]=='/') { + if (!$path || $path[0]=='/') { return substr($path, 1); - }else{ + } else { return $path; } } |