aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-09-12 22:53:10 +0200
committerRobin Appelman <icewind@owncloud.com>2012-09-12 22:53:10 +0200
commit68f65b657c398d44508d20b56ccf9ddbee8e3521 (patch)
tree54e25ec690b1f5b2d777956e681e7de8c067d96c
parente8d3a4768541980fcc391117e5a173875b2f75e0 (diff)
downloadnextcloud-server-68f65b657c398d44508d20b56ccf9ddbee8e3521.tar.gz
nextcloud-server-68f65b657c398d44508d20b56ccf9ddbee8e3521.zip
add OC_Filesystem::resolvePath to get the storage backend and internal path for a file in one go
-rw-r--r--lib/filesystem.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 9b022d8fef5..ef8b3fef5bb 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -194,6 +194,24 @@ class OC_Filesystem{
}
}
+ /**
+ * resolve a path to a storage and internal path
+ * @param string $path
+ * @return array consisting of the storage and the internal path
+ */
+ static public function resolvePath($path){
+ $mountpoint=self::getMountPoint($path);
+ if($mountpoint) {
+ if(!isset(OC_Filesystem::$storages[$mountpoint])) {
+ $mount=OC_Filesystem::$mounts[$mountpoint];
+ OC_Filesystem::$storages[$mountpoint]=OC_Filesystem::createStorage($mount['class'],$mount['arguments']);
+ }
+ $storage = OC_Filesystem::$storages[$mountpoint];
+ $internalPath=substr($path,strlen($mountpoint));
+ return array($storage, $internalPath);
+ }
+ }
+
static public function init($root) {
if(self::$defaultInstance) {
return false;