Commit bd834220 authored by Robin Appelman's avatar Robin Appelman
Browse files

put filestorages in a namespace

parent edcd2974
......@@ -30,7 +30,7 @@ class Test_CryptProxy extends UnitTestCase {
//set up temporary storage
OC_Filesystem::clearMounts();
OC_Filesystem::mount('OC_Filestorage_Temporary',array(),'/');
OC_Filesystem::mount('\OC\Files\Storage\Temporary',array(),'/');
OC_Filesystem::init('/'.$user.'/files');
......
......@@ -6,14 +6,14 @@
* See the COPYING-README file.
*/
OC::$CLASSPATH['OC_FileStorage_StreamWrapper']='apps/files_external/lib/streamwrapper.php';
OC::$CLASSPATH['OC_Filestorage_FTP']='apps/files_external/lib/ftp.php';
OC::$CLASSPATH['OC_Filestorage_DAV']='apps/files_external/lib/webdav.php';
OC::$CLASSPATH['OC_Filestorage_Google']='apps/files_external/lib/google.php';
OC::$CLASSPATH['OC_Filestorage_SWIFT']='apps/files_external/lib/swift.php';
OC::$CLASSPATH['OC_Filestorage_SMB']='apps/files_external/lib/smb.php';
OC::$CLASSPATH['OC_Filestorage_AmazonS3']='apps/files_external/lib/amazons3.php';
OC::$CLASSPATH['OC_Filestorage_Dropbox']='apps/files_external/lib/dropbox.php';
OC::$CLASSPATH['OC\Files\Storage\StreamWrapper']='apps/files_external/lib/streamwrapper.php';
OC::$CLASSPATH['OC\Files\Storage\FTP']='apps/files_external/lib/ftp.php';
OC::$CLASSPATH['OC\Files\Storage\DAV']='apps/files_external/lib/webdav.php';
OC::$CLASSPATH['OC\Files\Storage\Google']='apps/files_external/lib/google.php';
OC::$CLASSPATH['OC\Files\Storage\SWIFT']='apps/files_external/lib/swift.php';
OC::$CLASSPATH['OC\Files\Storage\SMB']='apps/files_external/lib/smb.php';
OC::$CLASSPATH['OC\Files\Storage\AmazonS3']='apps/files_external/lib/amazons3.php';
OC::$CLASSPATH['OC\Files\Storage\Dropbox']='apps/files_external/lib/dropbox.php';
OC::$CLASSPATH['OC_Mount_Config']='apps/files_external/lib/config.php';
OCP\App::registerAdmin('files_external', 'settings');
......
......@@ -22,7 +22,9 @@
require_once 'aws-sdk/sdk.class.php';
class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
namespace OC\Files\Storage;
class AmazonS3 extends \OC\Files\Storage\Common {
private $s3;
private $bucket;
......@@ -33,7 +35,7 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
// TODO options: storage class, encryption server side, encrypt before upload?
public function __construct($params) {
$this->s3 = new AmazonS3(array('key' => $params['key'], 'secret' => $params['secret']));
$this->s3 = new \AmazonS3(array('key' => $params['key'], 'secret' => $params['secret']));
$this->bucket = $params['bucket'];
}
......@@ -96,7 +98,7 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
foreach ($response->body->CommonPrefixes as $object) {
$files[] = basename($object->Prefix);
}
OC_FakeDirStream::$dirs['amazons3'.$path] = $files;
\OC_FakeDirStream::$dirs['amazons3'.$path] = $files;
return opendir('fakedir://amazons3'.$path);
}
return false;
......@@ -160,7 +162,7 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
switch ($mode) {
case 'r':
case 'rb':
$tmpFile = OC_Helper::tmpFile();
$tmpFile = \OC_Helper::tmpFile();
$handle = fopen($tmpFile, 'w');
$response = $this->s3->get_object($this->bucket, $path, array('fileDownload' => $handle));
if ($response->isOK()) {
......@@ -184,8 +186,8 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
} else {
$ext = '';
}
$tmpFile = OC_Helper::tmpFile($ext);
OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
$tmpFile = \OC_Helper::tmpFile($ext);
\OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
......
......@@ -39,14 +39,14 @@ class OC_Mount_Config {
*/
public static function getBackends() {
return array(
'OC_Filestorage_Local' => array('backend' => 'Local', 'configuration' => array('datadir' => 'Location')),
'OC_Filestorage_AmazonS3' => array('backend' => 'Amazon S3', 'configuration' => array('key' => 'Key', 'secret' => '*Secret', 'bucket' => 'Bucket')),
'OC_Filestorage_Dropbox' => array('backend' => 'Dropbox', 'configuration' => array('configured' => '#configured','app_key' => 'App key', 'app_secret' => 'App secret', 'token' => '#token', 'token_secret' => '#token_secret'), 'custom' => 'dropbox'),
'OC_Filestorage_FTP' => array('backend' => 'FTP', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'root' => '&Root', 'secure' => '!Secure ftps://')),
'OC_Filestorage_Google' => array('backend' => 'Google Drive', 'configuration' => array('configured' => '#configured', 'token' => '#token', 'token_secret' => '#token secret'), 'custom' => 'google'),
'OC_Filestorage_SWIFT' => array('backend' => 'OpenStack Swift', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'token' => '*Token', 'root' => '&Root', 'secure' => '!Secure ftps://')),
'OC_Filestorage_SMB' => array('backend' => 'SMB', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'share' => 'Share', 'root' => '&Root')),
'OC_Filestorage_DAV' => array('backend' => 'WebDAV', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'root' => '&Root', 'secure' => '!Secure https://'))
'\OC\Files\Storage\Local' => array('backend' => 'Local', 'configuration' => array('datadir' => 'Location')),
'\OC\Files\Storage\AmazonS3' => array('backend' => 'Amazon S3', 'configuration' => array('key' => 'Key', 'secret' => '*Secret', 'bucket' => 'Bucket')),
'\OC\Files\Storage\Dropbox' => array('backend' => 'Dropbox', 'configuration' => array('configured' => '#configured','app_key' => 'App key', 'app_secret' => 'App secret', 'token' => '#token', 'token_secret' => '#token_secret'), 'custom' => 'dropbox'),
'\OC\Files\Storage\FTP' => array('backend' => 'FTP', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'root' => '&Root', 'secure' => '!Secure ftps://')),
'\OC\Files\Storage\Google' => array('backend' => 'Google Drive', 'configuration' => array('configured' => '#configured', 'token' => '#token', 'token_secret' => '#token secret'), 'custom' => 'google'),
'\OC\Files\Storage\SWIFT' => array('backend' => 'OpenStack Swift', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'token' => '*Token', 'root' => '&Root', 'secure' => '!Secure ftps://')),
'\OC\Files\Storage\SMB' => array('backend' => 'SMB', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'share' => 'Share', 'root' => '&Root')),
'\OC\Files\Storage\DAV' => array('backend' => 'WebDAV', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'root' => '&Root', 'secure' => '!Secure https://'))
);
}
......@@ -124,7 +124,7 @@ class OC_Mount_Config {
if ($isPersonal) {
// Verify that the mount point applies for the current user
// Prevent non-admin users from mounting local storage
if ($applicable != OCP\User::getUser() || $class == 'OC_Filestorage_Local') {
if ($applicable != OCP\User::getUser() || $class == '\OC\Files\Storage\Local') {
return false;
}
$mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/');
......
......@@ -22,7 +22,9 @@
require_once 'Dropbox/autoload.php';
class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
namespace OC\Files\Storage;
class Dropbox extends \OC\Files\Storage\Common {
private $dropbox;
private $metaData = array();
......@@ -31,11 +33,11 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
public function __construct($params) {
if (isset($params['configured']) && $params['configured'] == 'true' && isset($params['app_key']) && isset($params['app_secret']) && isset($params['token']) && isset($params['token_secret'])) {
$oauth = new Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
$oauth = new \Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
$oauth->setToken($params['token'], $params['token_secret']);
$this->dropbox = new Dropbox_API($oauth, 'dropbox');
$this->dropbox = new \Dropbox_API($oauth, 'dropbox');
} else {
throw new Exception('Creating OC_Filestorage_Dropbox storage failed');
throw new \Exception('Creating \OC\Files\Storage\Dropbox storage failed');
}
}
......@@ -95,7 +97,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
foreach ($contents as $file) {
$files[] = basename($file['path']);
}
OC_FakeDirStream::$dirs['dropbox'.$path] = $files;
\OC_FakeDirStream::$dirs['dropbox'.$path] = $files;
return opendir('fakedir://dropbox'.$path);
}
return false;
......@@ -177,7 +179,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
switch ($mode) {
case 'r':
case 'rb':
$tmpFile = OC_Helper::tmpFile();
$tmpFile = \OC_Helper::tmpFile();
try {
$data = $this->dropbox->getFile($path);
file_put_contents($tmpFile, $data);
......@@ -203,8 +205,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
} else {
$ext = '';
}
$tmpFile = OC_Helper::tmpFile($ext);
OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
$tmpFile = \OC_Helper::tmpFile($ext);
\OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
......
......@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
namespace OC\Files\Storage;
class FTP extends \OC\Files\Storage\StreamWrapper{
private $password;
private $user;
private $host;
......@@ -69,7 +71,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$ext='';
}
$tmpFile=OCP\Files::tmpFile($ext);
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
\OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
if($this->file_exists($path)) {
$this->getFile($path,$tmpFile);
}
......
......@@ -22,7 +22,9 @@
require_once 'Google/common.inc.php';
class OC_Filestorage_Google extends OC_Filestorage_Common {
namespace OC\Files\Storage;
class Google extends \OC\Files\Storage\Common {
private $consumer;
private $oauth_token;
......@@ -35,12 +37,12 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
if (isset($params['configured']) && $params['configured'] == 'true' && isset($params['token']) && isset($params['token_secret'])) {
$consumer_key = isset($params['consumer_key']) ? $params['consumer_key'] : 'anonymous';
$consumer_secret = isset($params['consumer_secret']) ? $params['consumer_secret'] : 'anonymous';
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
$this->oauth_token = new OAuthToken($params['token'], $params['token_secret']);
$this->sig_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new \OAuthConsumer($consumer_key, $consumer_secret);
$this->oauth_token = new \OAuthToken($params['token'], $params['token_secret']);
$this->sig_method = new \OAuthSignatureMethod_HMAC_SHA1();
$this->entries = array();
} else {
throw new Exception('Creating OC_Filestorage_Google storage failed');
throw new \Exception('Creating \OC\Files\Storage\Google storage failed');
}
}
......@@ -96,7 +98,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
}
if ($isDownload) {
$tmpFile = OC_Helper::tmpFile();
$tmpFile = \OC_Helper::tmpFile();
$handle = fopen($tmpFile, 'w');
curl_setopt($curl, CURLOPT_FILE, $handle);
}
......@@ -399,7 +401,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
} else {
$ext = '';
}
$tmpFile = OC_Helper::tmpFile($ext);
$tmpFile = \OC_Helper::tmpFile($ext);
OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
......@@ -438,7 +440,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
}
if (isset($uploadUri) && $handle = fopen($path, 'r')) {
$uploadUri .= '?convert=false';
$mimetype = OC_Helper::getMimeType($path);
$mimetype = \OC_Helper::getMimeType($path);
$size = filesize($path);
$headers = array('X-Upload-Content-Type: ' => $mimetype, 'X-Upload-Content-Length: ' => $size);
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
......
......@@ -8,7 +8,9 @@
require_once 'smb4php/smb.php';
class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
namespace OC\Files\Storage;
class SMB extends \OC\Files\Storage\StreamWrapper{
private $password;
private $user;
private $host;
......
......@@ -6,8 +6,9 @@
* See the COPYING-README file.
*/
namespace OC\Files\Storage;
abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
abstract class StreamWrapper extends \OC\Files\Storage\Common{
abstract public function constructUrl($path);
public function mkdir($path) {
......@@ -84,6 +85,4 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
return stat($this->constructUrl($path));
}
}
......@@ -8,7 +8,9 @@
require_once 'php-cloudfiles/cloudfiles.php';
class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
namespace OC\Files\Storage;
class SWIFT extends \OC\Files\Storage\Common{
private $host;
private $root;
private $user;
......@@ -272,10 +274,10 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
if(!$this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
}
$this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);
$this->auth = new \CF_Authentication($this->user, $this->token, null, $this->host);
$this->auth->authenticate();
$this->conn = new CF_Connection($this->auth);
$this->conn = new \CF_Connection($this->auth);
if(!$this->containerExists($this->root)) {
$this->rootContainer=$this->createContainer('/');
......@@ -341,7 +343,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
$subContainers=$this->getSubContainers($container);
$files=array_merge($files,$subContainers);
$id=$this->getContainerName($path);
OC_FakeDirStream::$dirs[$id]=$files;
\OC_FakeDirStream::$dirs[$id]=$files;
return opendir('fakedir://'.$id);
}
......@@ -426,7 +428,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
case 'c':
case 'c+':
$tmpFile=$this->getTmpFile($path);
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
\OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
self::$tempFiles[$tmpFile]=$path;
return fopen('close://'.$tmpFile,$mode);
}
......
......@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
class OC_FileStorage_DAV extends OC_Filestorage_Common{
namespace OC\Files\Storage;
class DAV extends \OC\Files\Storage\Common{
private $password;
private $user;
private $host;
......@@ -42,7 +44,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
'password' => $this->password,
);
$this->client = new OC_Connector_Sabre_Client($settings);
$this->client = new \OC_Connector_Sabre_Client($settings);
if($caview = \OCP\Files::getStorage('files_external')) {
$certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt';
......@@ -78,12 +80,12 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
try{
$response=$this->client->propfind($path, array(),1);
$id=md5('webdav'.$this->root.$path);
OC_FakeDirStream::$dirs[$id]=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;
\OC_FakeDirStream::$dirs[$id][]=$file;
}
return opendir('fakedir://'.$id);
}catch(Exception $e) {
......@@ -161,7 +163,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$ext='';
}
$tmpFile=OCP\Files::tmpFile($ext);
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
\OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
if($this->file_exists($path)) {
$this->getFile($path,$tmpFile);
}
......
......@@ -24,7 +24,7 @@ OCP\Util::addScript('files_external', 'settings');
OCP\Util::addStyle('files_external', 'settings');
$backends = OC_Mount_Config::getBackends();
// Remove local storage
unset($backends['OC_Filestorage_Local']);
unset($backends['\OC\Files\Storage\Local']);
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('isAdminPage', false, false);
$tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints());
......
......@@ -34,7 +34,7 @@ if (!is_array($config) or !isset($config['amazons3']) or !$config['amazons3']['r
$id = uniqid();
$this->config = include('apps/files_external/tests/config.php');
$this->config['amazons3']['bucket'] = $id; // Make sure we have a new empty bucket to work in
$this->instance = new OC_Filestorage_AmazonS3($this->config['amazons3']);
$this->instance = new \OC\Files\Storage\AmazonS3($this->config['amazons3']);
}
public function tearDown() {
......
......@@ -18,7 +18,7 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']) {
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_FTP($this->config['ftp']);
$this->instance=new \OC\Files\Storage\FTP($this->config['ftp']);
}
public function tearDown() {
......
......@@ -33,7 +33,7 @@ if(!is_array($config) or !isset($config['google']) or !$config['google']['run'])
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_Google($this->config['google']);
$this->instance=new \OC\Files\Storage\Google($this->config['google']);
}
public function tearDown() {
......
......@@ -19,7 +19,7 @@ if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']) {
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['smb']['root'].=$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_SMB($this->config['smb']);
$this->instance=new \OC\Files\Storage\SMB($this->config['smb']);
}
public function tearDown() {
......
......@@ -18,7 +18,7 @@ if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']) {
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['swift']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_SWIFT($this->config['swift']);
$this->instance=new \OC\Files\Storage\SWIFT($this->config['swift']);
}
......
......@@ -18,7 +18,7 @@ if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run'])
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_DAV($this->config['webdav']);
$this->instance=new \OC\Files\Storage\DAV($this->config['webdav']);
}
public function tearDown() {
......
......@@ -2,8 +2,8 @@
OC::$CLASSPATH['OC_Share_Backend_File'] = "apps/files_sharing/lib/share/file.php";
OC::$CLASSPATH['OC_Share_Backend_Folder'] = 'apps/files_sharing/lib/share/folder.php';
OC::$CLASSPATH['OC_Filestorage_Shared'] = "apps/files_sharing/lib/sharedstorage.php";
OCP\Util::connectHook('OC_Filesystem', 'setup', 'OC_Filestorage_Shared', 'setup');
OC::$CLASSPATH['OC\Files\Storage\Shared'] = "apps/files_sharing/lib/sharedstorage.php";
OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
OCP\Util::addScript('files_sharing', 'share');
......@@ -20,10 +20,12 @@
*
*/
namespace OC\Files\Storage;
/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
class OC_Filestorage_Shared extends OC_Filestorage_Common {
class Shared extends \OC\Files\Storage\Common {
private $sharedFolder;
private $files = array();
......@@ -50,7 +52,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
if (isset($this->files[$folder])) {
$file = $this->files[$folder];
} else {
$file = OCP\Share::getItemSharedWith('folder', $folder, OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
$file = OCP\Share::getItemSharedWith('folder', $folder, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
}
if ($file) {
$this->files[$target]['path'] = $file['path'].substr($target, strlen($folder));
......@@ -58,7 +60,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
return $this->files[$target];
}
} else {
$file = OCP\Share::getItemSharedWith('file', $target, OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
$file = OCP\Share::getItemSharedWith('file', $target, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
if ($file) {
$this->files[$target] = $file;
return $this->files[$target];
......@@ -78,7 +80,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
$file = $this->getFile($target);
if (isset($file['path'])) {
$uid = substr($file['path'], 1, strpos($file['path'], '/', 1) - 1);
OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => OC_User::getHome($uid)), $uid);
\OC_Filesystem::mount('\OC\Files\Storage\Local', array('datadir' => \OC_User::getHome($uid)), $uid);
return $file['path'];
}
return false;
......@@ -103,7 +105,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
* @return Source file path with mount point stripped out
*/
private function getInternalPath($path) {
$mountPoint = OC_Filesystem::getMountPoint($path);
$mountPoint = \OC_Filesystem::getMountPoint($path);
$internalPath = substr($path, strlen($mountPoint));
return $internalPath;
}
......@@ -112,7 +114,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
if ($path == '' || $path == '/' || !$this->isCreatable(dirname($path))) {
return false;
} else if ($source = $this->getSourcePath($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->mkdir($this->getInternalPath($source));
}
return false;
......@@ -120,7 +122,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
public function rmdir($path) {
if (($source = $this->getSourcePath($path)) && $this->isDeletable($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->rmdir($this->getInternalPath($source));
}
return false;
......@@ -128,11 +130,11 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
public function opendir($path) {
if ($path == '' || $path == '/') {
$files = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_Folder::FORMAT_OPENDIR);
OC_FakeDirStream::$dirs['shared'] = $files;
$files = OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_Folder::FORMAT_OPENDIR);
\OC_FakeDirStream::$dirs['shared'] = $files;
return opendir('fakedir://shared');
} else if ($source = $this->getSourcePath($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->opendir($this->getInternalPath($source));
}
return false;
......@@ -142,7 +144,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
if ($path == '' || $path == '/') {
return true;
} else if ($source = $this->getSourcePath($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->is_dir($this->getInternalPath($source));
}
return false;
......@@ -150,7 +152,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
public function is_file($path) {
if ($source = $this->getSourcePath($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->is_file($this->getInternalPath($source));
}
return false;
......@@ -163,7 +165,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
$stat['ctime'] = $this->filectime($path);
return $stat;
} else if ($source = $this->getSourcePath($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->stat($this->getInternalPath($source));
}
return false;
......@@ -173,7 +175,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
if ($path == '' || $path == '/') {
return 'dir';
} else if ($source = $this->getSourcePath($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->filetype($this->getInternalPath($source));
}
return false;
......@@ -183,7 +185,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
if ($path == '' || $path == '/' || $this->is_dir($path)) {
return 0;
} else if ($source = $this->getSourcePath($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->filesize($this->getInternalPath($source));
}
return false;
......@@ -225,7 +227,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
if ($path == '' || $path == '/') {
return true;
} else if ($source = $this->getSourcePath($path)) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->file_exists($this->getInternalPath($source));
}
return false;
......@@ -246,7 +248,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
} else {
$source = $this->getSourcePath($path);
if ($source) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->filectime($this->getInternalPath($source));
}
}
......@@ -267,7 +269,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
} else {
$source = $this->getSourcePath($path);
if ($source) {
$storage = OC_Filesystem::getStorage($source);
$storage = \OC_Filesystem::getStorage($source);
return $storage->filemtime($this->getInternalPath($source));
}
}
......@@ -280,8 +282,8 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {