diff options
Diffstat (limited to 'lib/files.php')
-rw-r--r-- | lib/files.php | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/lib/files.php b/lib/files.php index 63dd96b9509..ac999a9bd15 100644 --- a/lib/files.php +++ b/lib/files.php @@ -29,6 +29,36 @@ class OC_Files { static $tmpFiles=array(); /** + * get the filesystem info + * @param string path + * @return array + * + * returns an associative array with the following keys: + * - size + * - mtime + * - ctime + * - mimetype + * - encrypted + * - versioned + */ + public static function getFileInfo($path) { + if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) { + if ($path == '/Shared') { + $info = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT); + } + else { + $path = substr($path, 7); + $info = OCP\Share::getItemSharedWith('file', $path, OC_Share_Backend_File::FORMAT_FILE_APP); + } + $info = $info[0]; + } + else { + $info = OC_FileCache::get($path); + } + return $info; + } + + /** * get the content of a directory * @param dir $directory path under datadirectory */ @@ -78,7 +108,24 @@ class OC_Files { return $files; } - + public static function searchByMime($mimetype_filter) { + $files = array(); + $dirs_to_check = array(''); + while (!empty($dirs_to_check)) { + // get next subdir to check + $dir = array_pop($dirs_to_check); + $dir_content = self::getDirectoryContent($dir, $mimetype_filter); + foreach($dir_content as $file) { + if ($file['type'] == 'file') { + $files[] = $dir.'/'.$file['name']; + } + else { + $dirs_to_check[] = $dir.'/'.$file['name']; + } + } + } + return $files; + } /** * return the content of a file or return a zip file containning multiply files |