22 changed files with 298 additions and 72 deletions
-
6apps/files_sharing/lib/external/manager.php
-
5apps/files_sharing/lib/external/mount.php
-
4apps/files_sharing/lib/sharedmount.php
-
55lib/private/files/config/mountprovidercollection.php
-
17lib/private/files/filesystem.php
-
16lib/private/files/mount/manager.php
-
22lib/private/files/mount/mountpoint.php
-
2lib/private/files/node/folder.php
-
14lib/private/files/node/root.php
-
13lib/private/files/storage/storagefactory.php
-
4lib/private/files/utils/scanner.php
-
4lib/private/files/view.php
-
12lib/private/server.php
-
26lib/public/files/config/imountprovider.php
-
31lib/public/files/config/imountprovidercollection.php
-
58lib/public/files/mount/imountpoint.php
-
32lib/public/files/storage/istoragefactory.php
-
5lib/public/iservercontainer.php
-
10tests/lib/files/mount/manager.php
-
10tests/lib/files/mount/mount.php
-
12tests/lib/files/node/folder.php
-
12tests/lib/files/utils/scanner.php
@ -0,0 +1,55 @@ |
|||
<?php |
|||
/** |
|||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. |
|||
* See the COPYING-README file. |
|||
*/ |
|||
|
|||
namespace OC\Files\Config; |
|||
|
|||
use OCP\Files\Config\IMountProviderCollection; |
|||
use OCP\Files\Config\IMountProvider; |
|||
use OCP\Files\Storage\IStorageFactory; |
|||
use OCP\IUser; |
|||
|
|||
class MountProviderCollection implements IMountProviderCollection { |
|||
/** |
|||
* @var \OCP\Files\Config\IMountProvider[] |
|||
*/ |
|||
private $providers = array(); |
|||
|
|||
/** |
|||
* @var \OCP\Files\Storage\IStorageFactory |
|||
*/ |
|||
private $loader; |
|||
|
|||
/** |
|||
* @param \OCP\Files\Storage\IStorageFactory $loader |
|||
*/ |
|||
public function __construct(IStorageFactory $loader) { |
|||
$this->loader = $loader; |
|||
} |
|||
|
|||
/** |
|||
* Get all configured mount points for the user |
|||
* |
|||
* @param \OCP\IUser $user |
|||
* @return \OCP\Files\Mount\IMountPoint[] |
|||
*/ |
|||
public function getMountsForUser(IUser $user) { |
|||
$loader = $this->loader; |
|||
return array_reduce($this->providers, function ($mounts, IMountProvider $provider) use ($user, $loader) { |
|||
return array_merge($mounts, $provider->getMountsForUser($user, $loader)); |
|||
}, array()); |
|||
} |
|||
|
|||
/** |
|||
* Add a provider for mount points |
|||
* |
|||
* @param \OCP\Files\Config\IMountProvider $provider |
|||
*/ |
|||
public function registerProvider(IMountProvider $provider) { |
|||
$this->providers[] = $provider; |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
<?php |
|||
/** |
|||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. |
|||
* See the COPYING-README file. |
|||
*/ |
|||
|
|||
namespace OCP\Files\Config; |
|||
|
|||
use OCP\Files\Storage\IStorageFactory; |
|||
use OCP\IUser; |
|||
|
|||
/** |
|||
* Provides |
|||
*/ |
|||
interface IMountProvider { |
|||
/** |
|||
* Get all mountpoints applicable for the user |
|||
* |
|||
* @param \OCP\IUser $user |
|||
* @param \OCP\Files\Storage\IStorageFactory $loader |
|||
* @return \OCP\Files\Mount\IMountPoint[] |
|||
*/ |
|||
public function getMountsForUser(IUser $user, IStorageFactory $loader); |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
/** |
|||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. |
|||
* See the COPYING-README file. |
|||
*/ |
|||
|
|||
namespace OCP\Files\Config; |
|||
|
|||
use OCP\IUser; |
|||
|
|||
/** |
|||
* Manages the different mount providers |
|||
*/ |
|||
interface IMountProviderCollection { |
|||
/** |
|||
* Get all configured mount points for the user |
|||
* |
|||
* @param \OCP\IUser $user |
|||
* @return \OCP\Files\Mount\IMountPoint[] |
|||
*/ |
|||
public function getMountsForUser(IUser $user); |
|||
|
|||
/** |
|||
* Add a provider for mount points |
|||
* |
|||
* @param \OCP\Files\Config\IMountProvider $provider |
|||
*/ |
|||
public function registerProvider(IMountProvider $provider); |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
<?php |
|||
/** |
|||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. |
|||
* See the COPYING-README file. |
|||
*/ |
|||
|
|||
namespace OCP\Files\Mount; |
|||
|
|||
/** |
|||
* A storage mounted to folder on the filesystem |
|||
*/ |
|||
interface IMountPoint { |
|||
|
|||
/** |
|||
* get complete path to the mount point |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getMountPoint(); |
|||
|
|||
/** |
|||
* Set the mountpoint |
|||
* |
|||
* @param string $mountPoint new mount point |
|||
*/ |
|||
public function setMountPoint($mountPoint); |
|||
|
|||
/** |
|||
* Get the storage that is mounted |
|||
* |
|||
* @return \OC\Files\Storage\Storage |
|||
*/ |
|||
public function getStorage(); |
|||
|
|||
/** |
|||
* Get the id of the storages |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function getStorageId(); |
|||
|
|||
/** |
|||
* Get the path relative to the mountpoint |
|||
* |
|||
* @param string $path absolute path to a file or folder |
|||
* @return string |
|||
*/ |
|||
public function getInternalPath($path); |
|||
|
|||
/** |
|||
* Apply a storage wrapper to the mounted storage |
|||
* |
|||
* @param callable $wrapper |
|||
*/ |
|||
public function wrapStorage($wrapper); |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
/** |
|||
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> |
|||
* This file is licensed under the Affero General Public License version 3 or |
|||
* later. |
|||
* See the COPYING-README file. |
|||
*/ |
|||
|
|||
namespace OCP\Files\Storage; |
|||
|
|||
/** |
|||
* Creates storage instances and manages and applies storage wrappers |
|||
*/ |
|||
interface IStorageFactory { |
|||
/** |
|||
* allow modifier storage behaviour by adding wrappers around storages |
|||
* |
|||
* $callback should be a function of type (string $mountPoint, Storage $storage) => Storage |
|||
* |
|||
* @param string $wrapperName |
|||
* @param callable $callback |
|||
*/ |
|||
public function addStorageWrapper($wrapperName, $callback); |
|||
|
|||
/** |
|||
* @param string|boolean $mountPoint |
|||
* @param string $class |
|||
* @param array $arguments |
|||
* @return \OCP\Files\Storage |
|||
*/ |
|||
public function getInstance($mountPoint, $class, $arguments); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue