Select Git revision
filesystemview.php
-
Bart Visscher authoredBart Visscher authored
filesystemview.php 17.96 KiB
<?php
/**
* ownCloud
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* 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/>.
*/
/**
* Class to provide access to ownCloud filesystem via a "view", and methods for
* working with files within that view (e.g. read, write, delete, etc.). Each
* view is restricted to a set of directories via a virtual root. The default view
* uses the currently logged in user's data directory as root (parts of
* OC_Filesystem are merely a wrapper for OC_FilesystemView).
*
* Apps that need to access files outside of the user data folders (to modify files
* belonging to a user other than the one currently logged in, for example) should
* use this class directly rather than using OC_Filesystem, or making use of PHP's
* built-in file manipulation functions. This will ensure all hooks and proxies
* are triggered correctly.
*
* Filesystem functions are not called directly; they are passed to the correct
* OC_Filestorage object
*/
class OC_FilesystemView {
private $fakeRoot='';
private $internal_path_cache=array();
private $storage_cache=array();
public function __construct($root) {
$this->fakeRoot=$root;
}
public function getAbsolutePath($path) {
if(!$path){
$path='/';
}
if($path[0]!=='/'){
$path='/'.$path;
}
return $this->fakeRoot.$path;
}
/**
* change the root to a fake toor
* @param string fakeRoot
* @return bool
*/
public function chroot($fakeRoot) {
if(!$fakeRoot==''){
if($fakeRoot[0]!=='/') {
$fakeRoot='/'.$fakeRoot;
}
}