summaryrefslogtreecommitdiffstats
path: root/lib/filestorage.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-04-24 16:09:07 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-04-24 16:09:27 +0200
commitb7aba15f179125455298aaee411864ebf4ed86f9 (patch)
tree781cd833dfb6fa18eeb89967f3094dcf0fa5a33e /lib/filestorage.php
parent8d52fdb7faf4be4ed4282ecdd3e3a08af1fbf150 (diff)
downloadnextcloud-server-b7aba15f179125455298aaee411864ebf4ed86f9.tar.gz
nextcloud-server-b7aba15f179125455298aaee411864ebf4ed86f9.zip
add search functionality, for now only searches files but plugins/apps can extend that
Diffstat (limited to 'lib/filestorage.php')
-rw-r--r--lib/filestorage.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/filestorage.php b/lib/filestorage.php
index 3d0bdf4cc0e..429961b3d69 100644
--- a/lib/filestorage.php
+++ b/lib/filestorage.php
@@ -62,6 +62,7 @@ class OC_FILESTORAGE{
public function getTree($path){}
public function hash($type,$path,$raw){}
public function free_space($path){}
+ public function search($query){}
}
@@ -468,7 +469,25 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
public function free_space($path){
return disk_free_space($this->datadir.$path);
}
-
+
+ public function search($query){
+ return $this->searchInDir($query);
+ }
+
+ private function searchInDir($query,$dir=''){
+ $files=array();
+ foreach (scandir($this->datadir.$dir) as $item) {
+ if ($item == '.' || $item == '..') continue;
+ if(strstr(strtolower($item),strtolower($query))!==false){
+ $files[]=$dir.'/'.$item;
+ }
+ if(is_dir($this->datadir.$dir.'/'.$item)){
+ $files=array_merge($files,$this->searchInDir($query,$dir.'/'.$item));
+ }
+ }
+ return $files;
+ }
+
/**
* @brief get the size of folder and it's content
* @param string $path file path