.
*
*/
class OC_FilesystemView {
private $fakeRoot='';
public function __construct($root){
$this->fakeRoot=$root;
}
public function getAbsolutePath($path){
if(!$path){
$path='/';
}
if(substr($path,0,1)!=='/'){
$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;
}
}
$this->fakeRoot=$fakeRoot;
}
/**
* get the fake root
* @return string
*/
public function getRoot(){
return $this->fakeRoot;
}
/**
* get the part of the path relative to the mountpoint of the storage it's stored in
* @param string path
* @return bool
*/
public function getInternalPath($path){
return OC_Filesystem::getInternalPath($this->getAbsolutePath($path));
}
/**
* get the storage object for a path
* @param string path
* @return OC_Filestorage
*/
public function getStorage($path){
return OC_Filesystem::getStorage($this->getAbsolutePath($path));
}
/**
* get the mountpoint of the storage object for a path
( note: because a storage is not always mounted inside the fakeroot, the returned mountpoint is relative to the absolute root of the filesystem and doesn't take the chroot into account
*
* @param string path
* @return string
*/
public function getMountPoint($path){
return OC_Filesystem::getMountPoint($this->getAbsolutePath($path));
}
/**
* return the path to a local version of the file
* we need this because we can't know if a file is stored local or not from outside the filestorage and for some purposes a local file is needed
* @param string path
* @return string
*/
public function getLocalFile($path){
$parent=substr($path,0,strrpos($path,'/'));
if(OC_Filesystem::isValidPath($parent) and $storage=$this->getStorage($path)){
return $storage->getLocalFile($this->getInternalPath($path));
}
}
/**
* following functions are equivilent to their php buildin equivilents for arguments/return values.
*/
public function mkdir($path){
return $this->basicOperation('mkdir',$path,array('create','write'));
}
public function rmdir($path){
return $this->basicOperation('rmdir',$path,array('delete'));
}
public function opendir($path){
return $this->basicOperation('opendir',$path,array('read'));
}
public function is_dir($path){
if($path=='/'){
return true;
}
return $this->basicOperation('is_dir',$path);
}
public function is_file($path){
if($path=='/'){
return false;
}
return $this->basicOperation('is_file',$path);
}
public function stat($path){
return $this->basicOperation('stat',$path);
}
public function filetype($path){
return $this->basicOperation('filetype',$path);
}
public function filesize($path){
return $this->basicOperation('filesize',$path);
}
public function readfile($path){
@ob_end_clean();
$handle=$this->fopen($path,'r');
if ($handle) {
$chunkSize = 8*1024;// 1 MB chunks
while (!feof($handle)) {
echo fread($handle, $chunkSize);
flush();
}
$size=$this->filesize($path);
return $size;
}
return false;
}
public function is_readable($path){
return $this->basicOperation('is_readable',$path);
}
public function is_writable($path){
return $this->basicOperation('is_writable',$path);
}
public function file_exists($path){
if($path=='/'){
return true;
}
return $this->basicOperation('file_exists',$path);
}
public function filectime($path){
return $this->basicOperation('filectime',$path);
}
public function filemtime($path){
return $this->basicOperation('filemtime',$path);
}
public function touch($path, $mtime=null){
return $this->basicOperation('touch', $path, array('write'), $mtime);
}
public function file_get_contents($path){
return $this->basicOperation('file_get_contents',$path,array('read'));
}
public function file_put_contents($path,$data){
if(is_resource($data)){//not having to deal with streams in file_put_contents makes life easier
$exists=$this->file_exists($path);
$run=true;
if(!$exists){
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
}
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
if(!$run){
return false;
}
$target=$this->fopen($path,'w');
if($target){
$count=OC_Helper::streamCopy($data,$target);
fclose($target);
fclose($data);
if(!$exists){
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array( OC_Filesystem::signal_param_path => $path));
}
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array( OC_Filesystem::signal_param_path => $path));
return $count>0;
}else{
return false;
}
}else{
return $this->basicOperation('file_put_contents',$path,array('create','write'),$data);
}
}
public function unlink($path){
return $this->basicOperation('unlink',$path,array('delete'));
}
public function rename($path1,$path2){
if(OC_FileProxy::runPreProxies('rename',$path1,$path2) and OC_Filesystem::isValidPath($path2)){
$run=true;
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, array( OC_Filesystem::signal_param_oldpath => $path1 , OC_Filesystem::signal_param_newpath=>$path2, OC_Filesystem::signal_param_run => &$run));
if($run){
$mp1=$this->getMountPoint($path1);
$mp2=$this->getMountPoint($path2);
if($mp1==$mp2){
if($storage=$this->getStorage($path1)){
$result=$storage->rename($this->getInternalPath($path1),$this->getInternalPath($path2));
}
}else{
$source=$this->fopen($path1,'r');
$target=$this->fopen($path2,'w');
$count=OC_Helper::streamCopy($data,$target);
$storage1=$this->getStorage($path1);
$storage1->unlink($this->getInternalPath($path1));
$result=$count>0;
}
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, array( OC_Filesystem::signal_param_oldpath => $path1, OC_Filesystem::signal_param_newpath=>$path2));
return $result;
}
}
}
public function copy($path1,$path2){
if(OC_FileProxy::runPreProxies('copy',$path1,$path2) and $this->is_readable($path1) and OC_Filesystem::isValidPath($path2)){
$run=true;
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_copy, array( OC_Filesystem::signal_param_oldpath => $path1 , OC_Filesystem::signal_param_newpath=>$path2, OC_Filesystem::signal_param_run => &$run));
$exists=$this->file_exists($path2);
if($run and !$exists){
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array( OC_Filesystem::signal_param_path => $path2, OC_Filesystem::signal_param_run => &$run));
}
if($run){
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array( OC_Filesystem::signal_param_path => $path2, OC_Filesystem::signal_param_run => &$run));
}
if($run){
$mp1=$this->getMountPoint($path1);
$mp2=$this->getMountPoint($path2);
if($mp1==$mp2){
if($storage=$this->getStorage($path1)){
$result=$storage->copy($this->getInternalPath($path1),$this->getInternalPath($path2));
}
}else{
$source=$this->fopen($path1,'r');
$target=$this->fopen($path2,'w');
$count=OC_Helper::streamCopy($data,$target);
}
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_copy, array( OC_Filesystem::signal_param_oldpath => $path1 , OC_Filesystem::signal_param_newpath=>$path2));
if(!$exists){
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array( OC_Filesystem::signal_param_path => $path2));
}
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array( OC_Filesystem::signal_param_path => $path2));
return $result;
}
}
}
public function fopen($path,$mode){
$hooks=array();
switch($mode){
case 'r':
case 'rb':
$hooks[]='read';
break;
case 'r+':
case 'rb+':
case 'w+':
case 'wb+':
case 'x+':
case 'xb+':
case 'a+':
case 'ab+':
$hooks[]='read';
$hooks[]='write';
break;
case 'w':
case 'wb':
case 'x':
case 'xb':
case 'a':
case 'ab':
$hooks[]='write';
break;
default:
OC_Log::write('core','invalid mode ('.$mode.') for '.$path,OC_Log::ERROR);
}
return $this->basicOperation('fopen',$path,$hooks,$mode);
}
public function toTmpFile($path){
if(OC_Filesystem::isValidPath($path)){
$source=$this->fopen($path,'r');
if($source){
$extension='';
$extOffset=strpos($path,'.');
if($extOffset !== false) {
$extension=substr($path,strrpos($path,'.'));
}
$tmpFile=OC_Helper::tmpFile($extension);
file_put_contents($tmpFile,$source);
return $tmpFile;
}
}
}
public function fromTmpFile($tmpFile,$path){
if(OC_Filesystem::isValidPath($path)){
if(!$tmpFile){
debug_print_backtrace();
}
$source=fopen($tmpFile,'r');
if($source){
$this->file_put_contents($path,$source);
unlink($tmpFile);
return true;
}else{
}
}else{
return false;
}
}
public function getMimeType($path){
return $this->basicOperation('getMimeType',$path);
}
public function hash($type,$path){
return $this->basicOperation('hash',$path,array('read'));
}
public function free_space($path='/'){
return $this->basicOperation('free_space',$path);
}
/**
* abstraction for running most basic operations
* @param string $operation
* @param string #path
* @param array (optional) hooks
* @param mixed (optional) $extraParam
* @return mixed
*/
private function basicOperation($operation,$path,$hooks=array(),$extraParam=null){
if(OC_FileProxy::runPreProxies($operation,$path, $extraParam) and OC_Filesystem::isValidPath($path)){
$interalPath=$this->getInternalPath($path);
$run=true;
if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()){
foreach($hooks as $hook){
if($hook!='read'){
OC_Hook::emit( OC_Filesystem::CLASSNAME, $hook, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
}else{
OC_Hook::emit( OC_Filesystem::CLASSNAME, $hook, array( OC_Filesystem::signal_param_path => $path));
}
}
}
if($run and $storage=$this->getStorage($path)){
if(!is_null($extraParam)){
$result=$storage->$operation($interalPath,$extraParam);
}else{
$result=$storage->$operation($interalPath);
}
$result=OC_FileProxy::runPostProxies($operation,$path,$result);
if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()){
if($operation!='fopen'){//no post hooks for fopen, the file stream is still open
foreach($hooks as $hook){
if($hook!='read'){
OC_Hook::emit( OC_Filesystem::CLASSNAME, 'post_'.$hook, array( OC_Filesystem::signal_param_path => $path));
}
}
}
}
return $result;
}
}
return null;
}
}
5/stable30
Nextcloud server, a safe home for all your data: https://github.com/nextcloud/server
# SOME DESCRIPTIVE TITLE.# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER# This file is distributed under the same license as the PACKAGE package.# # Translators:# hlx98007 <hlx98007@gmail.com>, 2013msgid""msgstr"""Project-Id-Version: ownCloud\n""Report-Msgid-Bugs-To: http://bugs.owncloud.org/\n""POT-Creation-Date: 2013-07-15 02:24+0200\n""PO-Revision-Date: 2013-07-14 23:25+0000\n""Last-Translator: hlx98007 <hlx98007@gmail.com>\n""Language-Team: Chinese (China) (GB2312) (http://www.transifex.com/projects/p/owncloud/language/zh_CN.GB2312/)\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n""Language: zh_CN.GB2312\n""Plural-Forms: nplurals=1; plural=0;\n"#: ajax/move.php:17#, php-formatmsgid"Could not move %s - File with this name already exists"msgstr"无法移动 %s - 存在同名文件"#: ajax/move.php:27 ajax/move.php:30#, php-formatmsgid"Could not move %s"msgstr"无法移动 %s"#: ajax/upload.php:16 ajax/upload.php:45msgid"Unable to set upload directory."msgstr"无法设置上传文件夹"#: ajax/upload.php:22msgid"Invalid Token"msgstr"非法Token"#: ajax/upload.php:59msgid"No file was uploaded. Unknown error"msgstr"没有上传文件。未知错误"#: ajax/upload.php:66msgid"There is no error, the file uploaded with success"msgstr"文件上传成功"#: ajax/upload.php:67msgid"""The uploaded file exceeds the upload_max_filesize directive in php.ini: "msgstr"上传的文件超过了php.ini指定的upload_max_filesize"#: ajax/upload.php:69msgid"""The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in ""the HTML form"msgstr"上传的文件超过了 HTML 表格中指定的 MAX_FILE_SIZE 选项"#: ajax/upload.php:70msgid"The uploaded file was only partially uploaded"msgstr"文件部分上传"#: ajax/upload.php:71msgid"No file was uploaded"msgstr"没有上传文件"#: ajax/upload.php:72msgid"Missing a temporary folder"msgstr"缺失临时文件夹"#: ajax/upload.php:73msgid"Failed to write to disk"msgstr"写磁盘失败"#: ajax/upload.php:91msgid"Not enough storage available"msgstr"容量不足"#: ajax/upload.php:123msgid"Invalid directory."msgstr"无效文件夹"#: appinfo/app.php:12msgid"Files"msgstr"文件"#: js/file-upload.js:11msgid"Unable to upload your file as it is a directory or has 0 bytes"msgstr"不能上传您的文件,由于它是文件夹或者为空文件"#: js/file-upload.js:24msgid"Not enough space available"msgstr"容量不足"#: js/file-upload.js:64msgid"Upload cancelled."msgstr"上传取消了"#: js/file-upload.js:167 js/files.js:266msgid"""File upload is in progress. Leaving the page now will cancel the upload."msgstr"文件正在上传。关闭页面会取消上传。"#: js/file-upload.js:233 js/files.js:339msgid"URL cannot be empty."msgstr"网址不能为空。"#: js/file-upload.js:238 lib/app.php:53msgid"Invalid folder name. Usage of 'Shared' is reserved by ownCloud"msgstr"无效文件夹名。“Shared”已经被系统保留。"#: js/file-upload.js:267 js/file-upload.js:283 js/files.js:373 js/files.js:389#: js/files.js:693 js/files.js:731msgid"Error"msgstr"出错"#: js/fileactions.js:116msgid"Share"msgstr"分享"#: js/fileactions.js:126msgid"Delete permanently"msgstr"永久删除"#: js/fileactions.js:128 templates/index.php:93 templates/index.php:94msgid"Delete"msgstr"删除"#: js/fileactions.js:194msgid"Rename"msgstr"重命名"#: js/filelist.js:49 js/filelist.js:52 js/filelist.js:466msgid"Pending"msgstr"等待中"#: js/filelist.js:304 js/filelist.js:306msgid"{new_name} already exists"msgstr"{new_name} 已存在"#: js/filelist.js:304 js/filelist.js:306msgid"replace"msgstr"替换"#: js/filelist.js:304msgid"suggest name"msgstr"推荐名称"#: js/filelist.js:304 js/filelist.js:306msgid"cancel"msgstr"取消"#: js/filelist.js:351msgid"replaced {new_name} with {old_name}"msgstr"已用 {old_name} 替换 {new_name}"#: js/filelist.js:351msgid"undo"msgstr"撤销"#: js/filelist.js:376msgid"perform delete operation"msgstr"执行删除"#: js/filelist.js:458msgid"1 file uploading"msgstr"1 个文件正在上传"#: js/filelist.js:461 js/filelist.js:519msgid"files uploading"msgstr"个文件正在上传"#: js/files.js:52msgid"'.' is an invalid file name."msgstr"'.' 文件名不正确"#: js/files.js:56msgid"File name cannot be empty."msgstr"文件名不能为空"#: js/files.js:64msgid"""Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not ""allowed."msgstr"文件名内不能包含以下符号:\\ / < > : \" | ?和 *"#: js/files.js:78msgid"Your storage is full, files can not be updated or synced anymore!"msgstr"容量已满,不能再同步/上传文件了!"#: js/files.js:82msgid"Your storage is almost full ({usedSpacePercent}%)"msgstr"你的空间快用满了 ({usedSpacePercent}%)"#: js/files.js:231msgid"""Your download is being prepared. This might take some time if the files are ""big."msgstr"正在下载,可能会花点时间,跟文件大小有关"#: js/files.js:344msgid"Invalid folder name. Usage of 'Shared' is reserved by Owncloud"msgstr"不正确文件夹名。Shared是保留名,不能使用。"#: js/files.js:744 templates/index.php:69msgid"Name"msgstr"名称"#: js/files.js:745msgid"Size"msgstr"大小"#: js/files.js:746 templates/index.php:82msgid"Modified"msgstr"修改日期"#: js/files.js:765msgid"1 folder"msgstr"1 个文件夹"#: js/files.js:767msgid"{count} folders"msgstr"{count} 个文件夹"#: js/files.js:775msgid"1 file"msgstr"1 个文件"#: js/files.js:777msgid"{count} files"msgstr"{count} 个文件"#: lib/app.php:73#, php-formatmsgid"%s could not be renamed"msgstr"不能重命名 %s"#: lib/helper.php:11 templates/index.php:18msgid"Upload"msgstr"上传"#: templates/admin.php:5msgid"File handling"msgstr"文件处理中"#: templates/admin.php:7msgid"Maximum upload size"msgstr"最大上传大小"#: templates/admin.php:10msgid"max. possible: "msgstr"最大可能"#: templates/admin.php:15msgid"Needed for multi-file and folder downloads."msgstr"需要多文件和文件夹下载."#: templates/admin.php:17msgid"Enable ZIP-download"msgstr"支持ZIP下载"#: templates/admin.php:20msgid"0 is unlimited"msgstr"0是无限的"#: templates/admin.php:22msgid"Maximum input size for ZIP files"msgstr"最大的ZIP文件输入大小"#: templates/admin.php:26msgid"Save"msgstr"保存"#: templates/index.php:7msgid"New"msgstr"新建"#: templates/index.php:10msgid"Text file"msgstr"文本文档"#: templates/index.php:12msgid"Folder"msgstr"文件夹"#: templates/index.php:14msgid"From link"msgstr"来自链接"#: templates/index.php:42msgid"Deleted files"msgstr"已删除的文件"#: templates/index.php:48msgid"Cancel upload"msgstr"取消上传"#: templates/index.php:54msgid"You don’t have write permissions here."msgstr"您没有写入权限。"#: templates/index.php:61msgid"Nothing in here. Upload something!"msgstr"这里没有东西.上传点什么!"#: templates/index.php:75msgid"Download"msgstr"下载"#: templates/index.php:80msgid"Size (MB)"msgstr"大小 (MB)"#: templates/index.php:87 templates/index.php:88msgid"Unshare"msgstr"取消分享"#: templates/index.php:107msgid"Upload too large"msgstr"上传过大"#: templates/index.php:109msgid"""The files you are trying to upload exceed the maximum size for file uploads ""on this server."msgstr"你正在试图上传的文件超过了此服务器支持的最大的文件大小."#: templates/index.php:114msgid"Files are being scanned, please wait."msgstr"正在扫描文件,请稍候."#: templates/index.php:117msgid"Current scanning"msgstr"正在扫描"#: templates/part.list.php:76msgid"directory"msgstr"文件夹"#: templates/part.list.php:78msgid"directories"msgstr"文件夹"#: templates/part.list.php:87msgid"file"msgstr"文件"#: templates/part.list.php:89msgid"files"msgstr"文件"#: templates/upgrade.php:2msgid"Upgrading filesystem cache..."msgstr"升级系统缓存..."