Merge pull request #4898 from owncloud/server_folder_methods

Server folder methods
This commit is contained in:
Thomas Müller 2013-09-24 06:58:47 -07:00
commit 843f15f348
2 changed files with 51 additions and 0 deletions

View File

@ -62,6 +62,20 @@ interface IServerContainer {
*/
function getRootFolder();
/**
* Returns a view to ownCloud's files folder
*
* @return \OCP\Files\Folder
*/
function getUserFolder();
/**
* Returns an app-specific view in ownClouds data directory
*
* @return \OCP\Files\Folder
*/
function getAppFolder();
/**
* Returns the user session
*

View File

@ -148,6 +148,42 @@ class Server extends SimpleContainer implements IServerContainer {
return $this->query('RootFolder');
}
/**
* Returns a view to ownCloud's files folder
*
* @return \OCP\Files\Folder
*/
function getUserFolder() {
$dir = '/files';
$root = $this->getRootFolder();
$folder = null;
if(!$root->nodeExists($dir)) {
$folder = $root->newFolder($dir);
} else {
$folder = $root->get($dir);
}
return $folder;
}
/**
* Returns an app-specific view in ownClouds data directory
*
* @return \OCP\Files\Folder
*/
function getAppFolder() {
$dir = '/' . \OC_App::getCurrentApp();
$root = $this->getRootFolder();
$folder = null;
if(!$root->nodeExists($dir)) {
$folder = $root->newFolder($dir);
} else {
$folder = $root->get($dir);
}
return $folder;
}
/**
* @return \OC\User\Manager
*/
@ -175,6 +211,7 @@ class Server extends SimpleContainer implements IServerContainer {
function getConfig() {
return $this->query('AllConfig');
}
/**
* Returns an ICache instance
*