summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-01-28 15:34:15 +0100
committerRobin Appelman <icewind@owncloud.com>2013-01-28 15:34:15 +0100
commitc9c919da5738f963247307ca3878e06beff87ade (patch)
tree6b4a0c381fef34589559634555a653a57821002d /apps/files_external/lib
parentbca5ce724e4fcecfe89da8839878c4da6f102e35 (diff)
downloadnextcloud-server-c9c919da5738f963247307ca3878e06beff87ade.tar.gz
nextcloud-server-c9c919da5738f963247307ca3878e06beff87ade.zip
Move streamwrappers to seperate files and put them in a namespace
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/amazons3.php54
-rwxr-xr-xapps/files_external/lib/dropbox.php4
-rw-r--r--apps/files_external/lib/ftp.php2
-rw-r--r--apps/files_external/lib/google.php4
-rw-r--r--apps/files_external/lib/swift.php4
-rw-r--r--apps/files_external/lib/webdav.php6
6 files changed, 38 insertions, 36 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index a209f0d0507..494885a1dd3 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -1,24 +1,24 @@
<?php
/**
-* ownCloud
-*
-* @author Michael Gapczynski
-* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
+ * ownCloud
+ *
+ * @author Michael Gapczynski
+ * @copyright 2012 Michael Gapczynski mtgap@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
namespace OC\Files\Storage;
@@ -36,7 +36,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
// TODO options: storage class, encryption server side, encrypt before upload?
public function __construct($params) {
- $this->id = 'amazon::'.$params['key'] . md5($params['secret']);
+ $this->id = 'amazon::' . $params['key'] . md5($params['secret']);
$this->s3 = new \AmazonS3(array('key' => $params['key'], 'secret' => $params['secret']));
$this->bucket = $params['bucket'];
}
@@ -51,7 +51,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return $response;
// This object could be a folder, a '/' must be at the end of the path
} else if (substr($path, -1) != '/') {
- $response = $this->s3->get_object_metadata($this->bucket, $path.'/');
+ $response = $this->s3->get_object_metadata($this->bucket, $path . '/');
if ($response) {
$this->objects[$path] = $response;
return $response;
@@ -61,7 +61,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return false;
}
- public function getId(){
+ public function getId() {
return $this->id;
}
@@ -104,8 +104,8 @@ class AmazonS3 extends \OC\Files\Storage\Common {
foreach ($response->body->CommonPrefixes as $object) {
$files[] = basename($object->Prefix);
}
- \OC_FakeDirStream::$dirs['amazons3'.$path] = $files;
- return opendir('fakedir://amazons3'.$path);
+ \OC\Files\Stream\Dir::register('amazons3' . $path, $files);
+ return opendir('fakedir://amazons3' . $path);
}
return false;
}
@@ -194,13 +194,13 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$ext = '';
}
$tmpFile = \OC_Helper::tmpFile($ext);
- \OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
}
self::$tempFiles[$tmpFile] = $path;
- return fopen('close://'.$tmpFile, $mode);
+ return fopen('close://' . $tmpFile, $mode);
}
return false;
}
@@ -209,8 +209,8 @@ class AmazonS3 extends \OC\Files\Storage\Common {
if (isset(self::$tempFiles[$tmpFile])) {
$handle = fopen($tmpFile, 'r');
$response = $this->s3->create_object($this->bucket,
- self::$tempFiles[$tmpFile],
- array('fileUpload' => $handle));
+ self::$tempFiles[$tmpFile],
+ array('fileUpload' => $handle));
if ($response->isOK()) {
unlink($tmpFile);
}
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 9223b4ca87b..11644e4a2c8 100755
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -114,7 +114,7 @@ class Dropbox extends \OC\Files\Storage\Common {
foreach ($contents as $file) {
$files[] = basename($file['path']);
}
- \OC_FakeDirStream::$dirs['dropbox'.$path] = $files;
+ \OC\Files\Stream\Dir::register('dropbox'.$path, $files);
return opendir('fakedir://dropbox'.$path);
}
return false;
@@ -232,7 +232,7 @@ class Dropbox extends \OC\Files\Storage\Common {
$ext = '';
}
$tmpFile = \OC_Helper::tmpFile($ext);
- \OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
index 973b33fbfd7..9a27b63323a 100644
--- a/apps/files_external/lib/ftp.php
+++ b/apps/files_external/lib/ftp.php
@@ -84,7 +84,7 @@ class FTP extends \OC\Files\Storage\StreamWrapper{
$ext='';
}
$tmpFile=OCP\Files::tmpFile($ext);
- OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$this->getFile($path, $tmpFile);
}
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index 4c485773e7b..7396c7e3f27 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -273,7 +273,7 @@ class Google extends \OC\Files\Storage\Common {
$this->entries[$name] = $entry;
}
}
- \OC_FakeDirStream::$dirs['google'.$path] = $files;
+ \OC\Files\Stream\Dir::register('google'.$path, $files);
return opendir('fakedir://google'.$path);
}
@@ -450,7 +450,7 @@ class Google extends \OC\Files\Storage\Common {
$ext = '';
}
$tmpFile = \OC_Helper::tmpFile($ext);
- \OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index bd1f4c572a6..cbf2007052b 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -371,7 +371,7 @@ class SWIFT extends \OC\Files\Storage\Common{
$subContainers=$this->getSubContainers($container);
$files=array_merge($files, $subContainers);
$id=$this->getContainerName($path);
- \OC_FakeDirStream::$dirs[$id]=$files;
+ \OC\Files\Stream\Dir::register($id, $files);
return opendir('fakedir://'.$id);
}
@@ -465,7 +465,7 @@ class SWIFT extends \OC\Files\Storage\Common{
case 'c':
case 'c+':
$tmpFile=$this->getTmpFile($path);
- OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
self::$tempFiles[$tmpFile]=$path;
return fopen('close://'.$tmpFile, $mode);
}
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 6d43a03058a..571b4d79ae2 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -104,13 +104,15 @@ class DAV extends \OC\Files\Storage\Common{
try {
$response=$this->client->propfind($path, array(), 1);
$id=md5('webdav'.$this->root.$path);
+ $content = array();
\OC_FakeDirStream::$dirs[$id]=array();
$files=array_keys($response);
array_shift($files);//the first entry is the current directory
foreach ($files as $file) {
$file = urldecode(basename($file));
- \OC_FakeDirStream::$dirs[$id][]=$file;
+ $content[]=$file;
}
+ \OC\Files\Stream\Dir::register($id, $content);
return opendir('fakedir://'.$id);
} catch(\Exception $e) {
return false;
@@ -194,7 +196,7 @@ class DAV extends \OC\Files\Storage\Common{
$ext='';
}
$tmpFile = \OCP\Files::tmpFile($ext);
- \OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if($this->file_exists($path)) {
$this->getFile($path, $tmpFile);
}