public function getMimeType($fspath) { if ($this->is_readable($fspath)) { if (@is_dir($this->datadir . $fspath)) { // directories are easy return "httpd/unix-directory"; } elseif (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); return $mimeType; } else { if (function_exists("mime_content_type")) { // use mime magic extension if available $mime_type = mime_content_type($this->datadir . $fspath); } else { if (OC_Helper::canExecute("file")) { // it looks like we have a 'file' command, // lets see it it does have mime support $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 $mime_type = substr($reply, 0, strrpos($reply, ' ')); } } } if (empty($mime_type)) { // Fallback solution: (try to guess the type by the file extension if (!self::$mimetypes) { self::$mimetypes = (include 'mimetypes.list.php'); } $extention = strtolower(strrchr(basename($fspath), ".")); $extention = substr($extention, 1); //remove leading . $mime_type = isset(self::$mimetypes[$extention]) ? self::$mimetypes[$extention] : 'application/octet-stream'; } return $mime_type; } }
public function readdir($handle) { $fsLocal = new OC_Filestorage_Local(array('datadir' => '/')); return $fsLocal->readdir($handle); }