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:
authorRobin Appelman <icewind@owncloud.com>2012-03-02 21:42:04 +0400
committerRobin Appelman <icewind@owncloud.com>2012-03-02 21:42:57 +0400
commite8afe4f1588ad5697b8ef6627417dfeb4a6c0573 (patch)
tree594b6aa8ff154866c6371d30963c401cb11625d1 /lib/filestorage
parent4daedda35a3a8cffb283e47b37e66f5b0524cbd8 (diff)
add search implementation to filestorage common
Diffstat (limited to 'lib/filestorage')
-rw-r--r--lib/filestorage/common.php21
-rw-r--r--lib/filestorage/commontest.php3
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php
index fa14d7e99fd..fa0e7babf56 100644
--- a/lib/filestorage/common.php
+++ b/lib/filestorage/common.php
@@ -106,7 +106,9 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
return $hash;
}
// abstract public function free_space($path);
-// abstract public function search($query);
+ public function search($query){
+ return $this->searchInDir($query);
+ }
public function getLocalFile($path){
return $this->toTmpFile($path);
}
@@ -122,4 +124,21 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
return $tmpFile;
}
// abstract public function touch($path, $mtime=null);
+
+ protected function searchInDir($query,$dir=''){
+ $files=array();
+ $dh=$this->opendir($dir);
+ if($dh){
+ while($item=readdir($dh)){
+ if ($item == '.' || $item == '..') continue;
+ if(strstr(strtolower($item),strtolower($query))!==false){
+ $files[]=$dir.'/'.$item;
+ }
+ if($this->is_dir($dir.'/'.$item)){
+ $files=array_merge($files,$this->searchInDir($query,$dir.'/'.$item));
+ }
+ }
+ }
+ return $files;
+ }
}
diff --git a/lib/filestorage/commontest.php b/lib/filestorage/commontest.php
index 512e7c1b66d..1b01ff856a3 100644
--- a/lib/filestorage/commontest.php
+++ b/lib/filestorage/commontest.php
@@ -69,9 +69,6 @@ class OC_Filestorage_CommonTest extends OC_Filestorage_Common{
public function free_space($path){
return $this->storage->free_space($path);
}
- public function search($query){
- return $this->storage->search($query);
- }
public function touch($path, $mtime=null){
return $this->storage->touch($path,$mtime);
}