summaryrefslogtreecommitdiffstats
path: root/lib/files.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-11-09 18:41:57 +0100
committerRobin Appelman <icewind1991@gmail.com>2011-11-09 18:41:57 +0100
commit5a6aba1e1114707942c613c2402eed3237b43a21 (patch)
tree5cda68cc0256db5a3b3002fa694026d7d1475128 /lib/files.php
parent5cc6635eb81a8d76c04ee040a791f51ebbe389ef (diff)
downloadnextcloud-server-5a6aba1e1114707942c613c2402eed3237b43a21.tar.gz
nextcloud-server-5a6aba1e1114707942c613c2402eed3237b43a21.zip
provide caching for file metadata
Diffstat (limited to 'lib/files.php')
-rw-r--r--lib/files.php41
1 files changed, 5 insertions, 36 deletions
diff --git a/lib/files.php b/lib/files.php
index 88b559059f0..143aab5c72d 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -36,44 +36,13 @@ class OC_Files {
if(strpos($directory,OC::$CONFIG_DATADIRECTORY)===0){
$directory=substr($directory,strlen(OC::$CONFIG_DATADIRECTORY));
}
- $filesfound=true;
- $content=array();
- $dirs=array();
- $file=array();
- $files=array();
- if(OC_Filesystem::is_dir($directory)) {
- if ($dh = OC_Filesystem::opendir($directory)) {
- while (($filename = readdir($dh)) !== false) {
- if($filename<>'.' and $filename<>'..' and substr($filename,0,1)!='.'){
- $file=array();
- $filesfound=true;
- $file['name']=$filename;
- $file['directory']=$directory;
- $stat=OC_Filesystem::stat($directory.'/'.$filename);
- $file=array_merge($file,$stat);
- $file['size']=OC_Filesystem::filesize($directory.'/'.$filename);
- $file['mime']=OC_Files::getMimeType($directory .'/'. $filename);
- $file['readable']=OC_Filesystem::is_readable($directory .'/'. $filename);
- $file['writeable']=OC_Filesystem::is_writeable($directory .'/'. $filename);
- $file['type']=OC_Filesystem::filetype($directory .'/'. $filename);
- if($file['type']=='dir'){
- $dirs[$file['name']]=$file;
- }else{
- $files[$file['name']]=$file;
- }
- }
- }
- closedir($dh);
- }
+ $files=OC_FileCache::getFolderContent($directory);
+ foreach($files as &$file){
+ $file['directory']=$directory;
+ $file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file';
}
- uksort($dirs, "strnatcasecmp");
uksort($files, "strnatcasecmp");
- $content=array_merge($dirs,$files);
- if($filesfound){
- return $content;
- }else{
- return false;
- }
+ return $files;
}