summaryrefslogtreecommitdiffstats
path: root/apps/files_archive
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2012-08-26 17:30:07 +0200
committerFrank Karlitschek <frank@owncloud.org>2012-08-26 17:30:07 +0200
commit72e9a2ce57ee88503db83614cec5ccda71f0b58e (patch)
tree8bc301ca22d9ca08ea54426bcb61f62bd1c1cb75 /apps/files_archive
parent32bad688bdb4fea55eba9d4255fc55f1c60a0aca (diff)
downloadnextcloud-server-72e9a2ce57ee88503db83614cec5ccda71f0b58e.tar.gz
nextcloud-server-72e9a2ce57ee88503db83614cec5ccda71f0b58e.zip
moved to apps repository
Diffstat (limited to 'apps/files_archive')
-rw-r--r--apps/files_archive/appinfo/app.php13
-rw-r--r--apps/files_archive/appinfo/info.xml14
-rw-r--r--apps/files_archive/appinfo/version1
-rw-r--r--apps/files_archive/js/archive.js19
-rw-r--r--apps/files_archive/lib/storage.php174
-rw-r--r--apps/files_archive/tests/data/data.tar.gzbin4195 -> 0 bytes
-rw-r--r--apps/files_archive/tests/data/data.zipbin4705 -> 0 bytes
-rw-r--r--apps/files_archive/tests/data/lorem.txt4
-rw-r--r--apps/files_archive/tests/storage.php39
9 files changed, 0 insertions, 264 deletions
diff --git a/apps/files_archive/appinfo/app.php b/apps/files_archive/appinfo/app.php
deleted file mode 100644
index 67376c4a03a..00000000000
--- a/apps/files_archive/appinfo/app.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-OC::$CLASSPATH['OC_Filestorage_Archive']='apps/files_archive/lib/storage.php';
-
-OCP\Util::connectHook('OC_Filesystem','get_mountpoint','OC_Filestorage_Archive','autoMount');
-
-OCP\Util::addscript( 'files_archive', 'archive' );
diff --git a/apps/files_archive/appinfo/info.xml b/apps/files_archive/appinfo/info.xml
deleted file mode 100644
index 93ec68ee10d..00000000000
--- a/apps/files_archive/appinfo/info.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0"?>
-<info>
- <id>files_archive</id>
- <name>Archive support</name>
- <description>Transparent opening of archives</description>
- <licence>AGPL</licence>
- <author>Robin Appelman</author>
- <require>4</require>
- <shipped>true</shipped>
- <types>
- <filesystem/>
- </types>
- <default_enable/>
-</info>
diff --git a/apps/files_archive/appinfo/version b/apps/files_archive/appinfo/version
deleted file mode 100644
index 2f4536184bc..00000000000
--- a/apps/files_archive/appinfo/version
+++ /dev/null
@@ -1 +0,0 @@
-0.2 \ No newline at end of file
diff --git a/apps/files_archive/js/archive.js b/apps/files_archive/js/archive.js
deleted file mode 100644
index 6bcbe092662..00000000000
--- a/apps/files_archive/js/archive.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-$(document).ready(function() {
- if(typeof FileActions!=='undefined'){
- FileActions.register('application/zip','Open', FileActions.PERMISSION_READ, '',function(filename){
- window.location=OC.linkTo('files', 'index.php')+'&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
- });
- FileActions.setDefault('application/zip','Open');
- FileActions.register('application/x-gzip','Open', FileActions.PERMISSION_READ, '',function(filename){
- window.location=OC.linkTo('files', 'index.php')+'&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
- });
- FileActions.setDefault('application/x-gzip','Open');
- }
-});
diff --git a/apps/files_archive/lib/storage.php b/apps/files_archive/lib/storage.php
deleted file mode 100644
index 3c14c3e1fdf..00000000000
--- a/apps/files_archive/lib/storage.php
+++ /dev/null
@@ -1,174 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-class OC_Filestorage_Archive extends OC_Filestorage_Common{
- /**
- * underlying local storage used for missing functions
- * @var OC_Archive
- */
- private $archive;
- private $path;
- private static $mounted=array();
- private static $enableAutomount=true;
- private static $rootView;
-
- private function stripPath($path){//files should never start with /
- if(!$path || $path[0]=='/'){
- $path=substr($path,1);
- }
- return $path;
- }
-
- public function __construct($params){
- $this->archive=OC_Archive::open($params['archive']);
- $this->path=$params['archive'];
- }
-
- public function mkdir($path){
- $path=$this->stripPath($path);
- return $this->archive->addFolder($path);
- }
- public function rmdir($path){
- $path=$this->stripPath($path);
- return $this->archive->remove($path.'/');
- }
- public function opendir($path){
- if(substr($path,-1)!=='/'){
- $path.='/';
- }
- $path=$this->stripPath($path);
- $files=$this->archive->getFolder($path);
- $content=array();
- foreach($files as $file){
- if(substr($file,-1)=='/'){
- $file=substr($file,0,-1);
- }
- if($file and strpos($file,'/')===false){
- $content[]=$file;
- }
- }
- $id=md5($this->path.$path);
- OC_FakeDirStream::$dirs[$id]=$content;
- return opendir('fakedir://'.$id);
- }
- public function stat($path){
- $ctime=-1;
- $path=$this->stripPath($path);
- if($path==''){
- $stat=stat($this->path);
- $stat['size']=0;
- }else{
- if($this->is_dir($path)){
- $stat=array('size'=>0);
- $stat['mtime']=filemtime($this->path);
- }else{
- $stat=array();
- $stat['mtime']=$this->archive->mtime($path);
- $stat['size']=$this->archive->filesize($path);
- if(!$stat['mtime']){
- $stat['mtime']=time();
- }
- }
- }
- $stat['ctime']=$ctime;
- return $stat;
- }
- public function filetype($path){
- $path=$this->stripPath($path);
- if($path==''){
- return 'dir';
- }
- if(substr($path,-1)=='/'){
- return $this->archive->fileExists($path)?'dir':'file';
- }else{
- return $this->archive->fileExists($path.'/')?'dir':'file';
- }
- }
- public function isReadable($path){
- return is_readable($this->path);
- }
- public function isUpdatable($path){
- return is_writable($this->path);
- }
- public function file_exists($path){
- $path=$this->stripPath($path);
- if($path==''){
- return file_exists($this->path);
- }
- return $this->archive->fileExists($path);
- }
- public function unlink($path){
- $path=$this->stripPath($path);
- return $this->archive->remove($path);
- }
- public function fopen($path,$mode){
- $path=$this->stripPath($path);
- return $this->archive->getStream($path,$mode);
- }
- public function free_space($path){
- return 0;
- }
- public function touch($path, $mtime=null){
- if(is_null($mtime)){
- $tmpFile=OCP\Files::tmpFile();
- $this->archive->extractFile($path,$tmpFile);
- $this->archive->addfile($path,$tmpFile);
- }else{
- return false;//not supported
- }
- }
- private function toTmpFile($path){
- $tmpFile=OC_Helper::tmpFile($extension);
- $this->archive->extractFile($path,$tmpFile);
- return $tmpFile;
- }
- public function file_put_contents($path,$data) {
- $path=$this->stripPath($path);
- return $this->archive->addFile($path,$data);
- }
- public function file_get_contents($path) {
- $path=$this->stripPath($path);
- return $this->archive->getFile($path);
- }
-
- /**
- * automount paths from file hooks
- * @param aray params
- */
- public static function autoMount($params){
- if(!self::$enableAutomount){
- return;
- }
- $path=$params['path'];
- if(!self::$rootView){
- self::$rootView=new OC_FilesystemView('');
- }
- self::$enableAutomount=false;//prevent recursion
- $supported=array('zip','tar.gz','tar.bz2','tgz');
- foreach($supported as $type){
- $ext='.'.$type.'/';
- if(($pos=strpos(strtolower($path),$ext))!==false){
- $archive=substr($path,0,$pos+strlen($ext)-1);
- if(self::$rootView->file_exists($archive) and array_search($archive,self::$mounted)===false){
- $localArchive=self::$rootView->getLocalFile($archive);
- OC_Filesystem::mount('OC_Filestorage_Archive',array('archive'=>$localArchive),$archive.'/');
- self::$mounted[]=$archive;
- }
- }
- }
- self::$enableAutomount=true;
- }
-
- public function rename($path1,$path2){
- return $this->archive->rename($path1,$path2);
- }
-
- public function hasUpdated($path,$time){
- return $this->filemtime($this->path)>$time;
- }
-}
diff --git a/apps/files_archive/tests/data/data.tar.gz b/apps/files_archive/tests/data/data.tar.gz
deleted file mode 100644
index 39f2cdada02..00000000000
--- a/apps/files_archive/tests/data/data.tar.gz
+++ /dev/null
Binary files differ
diff --git a/apps/files_archive/tests/data/data.zip b/apps/files_archive/tests/data/data.zip
deleted file mode 100644
index eccef53eb4e..00000000000
--- a/apps/files_archive/tests/data/data.zip
+++ /dev/null
Binary files differ
diff --git a/apps/files_archive/tests/data/lorem.txt b/apps/files_archive/tests/data/lorem.txt
deleted file mode 100644
index b62c3fb2ffd..00000000000
--- a/apps/files_archive/tests/data/lorem.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
-Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \ No newline at end of file
diff --git a/apps/files_archive/tests/storage.php b/apps/files_archive/tests/storage.php
deleted file mode 100644
index 74ddf22870c..00000000000
--- a/apps/files_archive/tests/storage.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-class Test_Filestorage_Archive_Zip extends Test_FileStorage {
- /**
- * @var string tmpDir
- */
- private $tmpFile;
-
- public function setUp(){
- $this->tmpFile=OCP\Files::tmpFile('.zip');
- $this->instance=new OC_Filestorage_Archive(array('archive'=>$this->tmpFile));
- }
-
- public function tearDown(){
- unlink($this->tmpFile);
- }
-}
-
-class Test_Filestorage_Archive_Tar extends Test_FileStorage {
- /**
- * @var string tmpDir
- */
- private $tmpFile;
-
- public function setUp(){
- $this->tmpFile=OCP\Files::tmpFile('.tar.gz');
- $this->instance=new OC_Filestorage_Archive(array('archive'=>$this->tmpFile));
- }
-
- public function tearDown(){
- unlink($this->tmpFile);
- }
-}