aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/files/view.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-01-13 14:28:49 +0100
committerRobin Appelman <icewind@owncloud.com>2014-01-13 14:28:49 +0100
commit617acbd6f9e93254c31987639cc4915dceb7c4c0 (patch)
treef23296b22fbd833809ebf1ca5598208a425c1c31 /lib/private/files/view.php
parent85e00ad35a63d2d728140f3ece685d79d7a6140c (diff)
downloadnextcloud-server-617acbd6f9e93254c31987639cc4915dceb7c4c0.tar.gz
nextcloud-server-617acbd6f9e93254c31987639cc4915dceb7c4c0.zip
Add a FileInfo class which holds all info of a file and return that from getFileInfo, getDirectoryContent and search
Diffstat (limited to 'lib/private/files/view.php')
-rw-r--r--lib/private/files/view.php37
1 files changed, 20 insertions, 17 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 8893911ed5d..39c2ffed93d 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -781,14 +781,7 @@ class View {
* @param string $path
* @param boolean $includeMountPoints whether to add mountpoint sizes,
* defaults to true
- * @return array
- *
- * returns an associative array with the following keys:
- * - size
- * - mtime
- * - mimetype
- * - encrypted
- * - versioned
+ * @return \OC\Files\FileInfo | false
*/
public function getFileInfo($path, $includeMountPoints = true) {
$data = array();
@@ -838,10 +831,13 @@ class View {
$data['permissions'] = $permissions;
}
}
+ if (!$data) {
+ return false;
+ }
$data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data);
- return $data;
+ return new FileInfo($path, $storage, $internalPath, $data);
}
/**
@@ -849,7 +845,7 @@ class View {
*
* @param string $directory path under datadirectory
* @param string $mimetype_filter limit returned content to this mimetype or mimepart
- * @return array
+ * @return FileInfo[]
*/
public function getDirectoryContent($directory, $mimetype_filter = '') {
$result = array();
@@ -875,7 +871,11 @@ class View {
$watcher->checkUpdate($internalPath);
}
- $files = $cache->getFolderContents($internalPath); //TODO: mimetype_filter
+ $files = array();
+ $contents = $cache->getFolderContents($internalPath); //TODO: mimetype_filter
+ foreach ($contents as $content) {
+ $files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content);
+ }
$permissions = $permissionsCache->getDirectoryPermissions($cache->getId($internalPath), $user);
$ids = array();
@@ -933,7 +933,7 @@ class View {
break;
}
}
- $files[] = $rootEntry;
+ $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry);
}
}
}
@@ -955,6 +955,7 @@ class View {
$result = $files;
}
}
+
return $result;
}
@@ -992,7 +993,7 @@ class View {
* search for files with the name matching $query
*
* @param string $query
- * @return array
+ * @return FileInfo[]
*/
public function search($query) {
return $this->searchCommon('%' . $query . '%', 'search');
@@ -1002,7 +1003,7 @@ class View {
* search for files by mimetype
*
* @param string $mimetype
- * @return array
+ * @return FileInfo[]
*/
public function searchByMime($mimetype) {
return $this->searchCommon($mimetype, 'searchByMime');
@@ -1011,7 +1012,7 @@ class View {
/**
* @param string $query
* @param string $method
- * @return array
+ * @return FileInfo[]
*/
private function searchCommon($query, $method) {
$files = array();
@@ -1025,8 +1026,9 @@ class View {
$results = $cache->$method($query);
foreach ($results as $result) {
if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
+ $internalPath = $result['path'];
$result['path'] = substr($mountPoint . $result['path'], $rootLength);
- $files[] = $result;
+ $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result);
}
}
@@ -1040,8 +1042,9 @@ class View {
$results = $cache->$method($query);
if ($results) {
foreach ($results as $result) {
+ $internalPath = $result['path'];
$result['path'] = $relativeMountPoint . $result['path'];
- $files[] = $result;
+ $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result);
}
}
}