Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/filestorage')
-rw-r--r--lib/filestorage/local.php71
1 files changed, 4 insertions, 67 deletions
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 243fdd3ba6b..7d889fbce58 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -71,7 +71,7 @@ class OC_Filestorage_Local extends OC_Filestorage{
public function file_get_contents($path){
return file_get_contents($this->datadir.$path);
}
- public function file_put_contents($path,$data){
+ public function file_put_contents($path,$data=null){
if($return=file_put_contents($this->datadir.$path,$data)){
}
}
@@ -119,72 +119,9 @@ class OC_Filestorage_Local extends OC_Filestorage{
return $return;
}
- public function getMimeType($fspath){
- if($this->is_readable($fspath)){
- $mimeType='application/octet-stream';
- if ($mimeType=='application/octet-stream') {
- self::$mimetypes = include('mimetypes.fixlist.php');
- $extention=strtolower(strrchr(basename($fspath), "."));
- $extention=substr($extention,1);//remove leading .
- $mimeType=(isset(self::$mimetypes[$extention]))?self::$mimetypes[$extention]:'application/octet-stream';
-
- }
- if (@is_dir($this->datadir.$fspath)) {
- // directories are easy
- return "httpd/unix-directory";
- }
- if($mimeType=='application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)){
- $mimeType =strtolower(finfo_file($finfo,$this->datadir.$fspath));
- $mimeType=substr($mimeType,0,strpos($mimeType,';'));
- finfo_close($finfo);
- }
- if ($mimeType=='application/octet-stream' && function_exists("mime_content_type")) {
- // use mime magic extension if available
- $mimeType = mime_content_type($this->datadir.$fspath);
- }
- if ($mimeType=='application/octet-stream' && OC_Helper::canExecute("file")) {
- // it looks like we have a 'file' command,
- // lets see it it does have mime support
- $fspath=str_replace("'","\'",$fspath);
- $fp = popen("file -i -b '{$this->datadir}$fspath' 2>/dev/null", "r");
- $reply = fgets($fp);
- pclose($fp);
-
- //trim the character set from the end of the response
- $mimeType=substr($reply,0,strrpos($reply,' '));
- }
- if ($mimeType=='application/octet-stream') {
- // Fallback solution: (try to guess the type by the file extension
- if(!self::$mimetypes || self::$mimetypes != include('mimetypes.list.php')){
- self::$mimetypes=include('mimetypes.list.php');
- }
- $extention=strtolower(strrchr(basename($fspath), "."));
- $extention=substr($extention,1);//remove leading .
- $mimeType=(isset(self::$mimetypes[$extention]))?self::$mimetypes[$extention]:'application/octet-stream';
- }
- return $mimeType;
- }else{
- return false;
- }
- }
-
- public function toTmpFile($path){
- $tmpFolder=get_temp_dir();
- $filename=tempnam($tmpFolder,'OC_TEMP_FILE_'.substr($path,strrpos($path,'.')));
- $fileStats = stat($this->datadir.$path);
- if(copy($this->datadir.$path,$filename)){
- touch($filename, $fileStats['mtime'], $fileStats['atime']);
- return $filename;
- }else{
- return false;
- }
- }
-
- public function fromTmpFile($tmpFile,$path){
- $fileStats = stat($tmpFile);
- if(rename($tmpFile,$this->datadir.$path)){
- touch($this->datadir.$path, $fileStats['mtime'], $fileStats['atime']);
- return true;
+ public function getMimeType($path){
+ if($this->is_readable($path)){
+ return OC_Helper::getMimeType($this->datadir.$path);
}else{
return false;
}